home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / Mesa-3.0 / SRC / DLIST.C < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-21  |  88.9 KB  |  3,550 lines

  1. /* $Id: dlist.c,v 3.8 1998/08/21 02:48:14 brianp Exp $ */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  3.0
  6.  * Copyright (C) 1995-1998  Brian Paul
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU Library General Public
  10.  * License as published by the Free Software Foundation; either
  11.  * version 2 of the License, or (at your option) any later version.
  12.  *
  13.  * This library is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  * Library General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Library General Public
  19.  * License along with this library; if not, write to the Free
  20.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23.  
  24. /*
  25.  * $Log: dlist.c,v $
  26.  * Revision 3.8  1998/08/21 02:48:14  brianp
  27.  * fixed polygon stipple pointer casting typo
  28.  *
  29.  * Revision 3.7  1998/08/21 02:42:21  brianp
  30.  * changed gl_save_PolygonStipple() param type to GLuint *
  31.  *
  32.  * Revision 3.6  1998/06/07 22:18:52  brianp
  33.  * implemented GL_EXT_multitexture extension
  34.  *
  35.  * Revision 3.5  1998/03/28 03:58:52  brianp
  36.  * fixed a few IRIX compiler warnings
  37.  *
  38.  * Revision 3.4  1998/03/27 03:39:14  brianp
  39.  * fixed G++ warnings
  40.  *
  41.  * Revision 3.3  1998/03/19 01:26:39  brianp
  42.  * fixed API pointer restore problem in glCallList(s)
  43.  *
  44.  * Revision 3.2  1998/02/20 04:50:09  brianp
  45.  * implemented GL_SGIS_multitexture
  46.  *
  47.  * Revision 3.1  1998/02/08 20:23:09  brianp
  48.  * removed const from gl_save_Bitmap()'s bitmap parameter
  49.  *
  50.  * Revision 3.0  1998/01/31 20:50:39  brianp
  51.  * initial rev
  52.  *
  53.  */
  54.  
  55.  
  56. #ifdef PC_HEADER
  57. #include "all.h"
  58. #else
  59. #include <assert.h>
  60. #include <stdio.h>
  61. #include <stdlib.h>
  62. #include <string.h>
  63. #include "accum.h"
  64. #include "alpha.h"
  65. #include "attrib.h"
  66. #include "bitmap.h"
  67. #include "blend.h"
  68. #include "clip.h"
  69. #include "colortab.h"
  70. #include "context.h"
  71. #include "copypix.h"
  72. #include "depth.h"
  73. #include "drawpix.h"
  74. #include "enable.h"
  75. #include "eval.h"
  76. #include "feedback.h"
  77. #include "fog.h"
  78. #include "hash.h"
  79. #include "image.h"
  80. #include "light.h"
  81. #include "lines.h"
  82. #include "dlist.h"
  83. #include "logic.h"
  84. #include "macros.h"
  85. #include "masking.h"
  86. #include "matrix.h"
  87. #include "misc.h"
  88. #include "pixel.h"
  89. #include "points.h"
  90. #include "polygon.h"
  91. #include "rastpos.h"
  92. #include "rect.h"
  93. #include "scissor.h"
  94. #include "stencil.h"
  95. #include "texobj.h"
  96. #include "teximage.h"
  97. #include "texstate.h"
  98. #include "types.h"
  99. #include "vb.h"
  100. #include "vbfill.h"
  101. #include "winpos.h"
  102. #endif
  103.  
  104.  
  105.  
  106. /*
  107. Functions which aren't compiled but executed immediately:
  108.     glIsList
  109.     glGenLists
  110.     glDeleteLists
  111.     glEndList
  112.     glFeedbackBuffer
  113.     glSelectBuffer
  114.     glRenderMode
  115.     glReadPixels
  116.     glPixelStore
  117.     glFlush
  118.     glFinish
  119.     glIsEnabled
  120.     glGet*
  121.  
  122. Functions which cause errors if called while compiling a display list:
  123.     glNewList
  124. */
  125.  
  126.  
  127.  
  128. /*
  129.  * Display list instructions are stored as sequences of "nodes".  Nodes
  130.  * are allocated in blocks.  Each block has BLOCK_SIZE nodes.  Blocks
  131.  * are linked together with a pointer.
  132.  */
  133.  
  134.  
  135. /* How many nodes to allocate at a time: */
  136. #define BLOCK_SIZE 500
  137.  
  138.  
  139. /*
  140.  * Display list opcodes.
  141.  *
  142.  * The fact that these identifiers are assigned consecutive
  143.  * integer values starting at 0 is very important, see InstSize array usage)
  144.  */
  145. typedef enum {
  146.     OPCODE_ACCUM,
  147.     OPCODE_ALPHA_FUNC,
  148.         OPCODE_BEGIN,
  149.         OPCODE_BIND_TEXTURE,
  150.     OPCODE_BITMAP,
  151.     OPCODE_BLEND_COLOR,
  152.     OPCODE_BLEND_EQUATION,
  153.     OPCODE_BLEND_FUNC,
  154.         OPCODE_CALL_LIST,
  155.         OPCODE_CALL_LIST_OFFSET,
  156.     OPCODE_CLEAR,
  157.     OPCODE_CLEAR_ACCUM,
  158.     OPCODE_CLEAR_COLOR,
  159.     OPCODE_CLEAR_DEPTH,
  160.     OPCODE_CLEAR_INDEX,
  161.     OPCODE_CLEAR_STENCIL,
  162.         OPCODE_CLIP_PLANE,
  163.     OPCODE_COLOR_3F,
  164.     OPCODE_COLOR_4F,
  165.     OPCODE_COLOR_4UB,
  166.     OPCODE_COLOR_MASK,
  167.     OPCODE_COLOR_MATERIAL,
  168.     OPCODE_COLOR_TABLE,
  169.     OPCODE_COLOR_SUB_TABLE,
  170.     OPCODE_COPY_PIXELS,
  171.         OPCODE_COPY_TEX_IMAGE1D,
  172.         OPCODE_COPY_TEX_IMAGE2D,
  173.         OPCODE_COPY_TEX_IMAGE3D,
  174.         OPCODE_COPY_TEX_SUB_IMAGE1D,
  175.         OPCODE_COPY_TEX_SUB_IMAGE2D,
  176.         OPCODE_COPY_TEX_SUB_IMAGE3D,
  177.     OPCODE_CULL_FACE,
  178.     OPCODE_DEPTH_FUNC,
  179.     OPCODE_DEPTH_MASK,
  180.     OPCODE_DEPTH_RANGE,
  181.     OPCODE_DISABLE,
  182.     OPCODE_DRAW_BUFFER,
  183.     OPCODE_DRAW_PIXELS,
  184.         OPCODE_EDGE_FLAG,
  185.     OPCODE_ENABLE,
  186.         OPCODE_END,
  187.     OPCODE_EVALCOORD1,
  188.     OPCODE_EVALCOORD2,
  189.     OPCODE_EVALMESH1,
  190.     OPCODE_EVALMESH2,
  191.     OPCODE_EVALPOINT1,
  192.     OPCODE_EVALPOINT2,
  193.     OPCODE_FOG,
  194.     OPCODE_FRONT_FACE,
  195.     OPCODE_FRUSTUM,
  196.     OPCODE_HINT,
  197.     OPCODE_INDEX,
  198.     OPCODE_INDEX_MASK,
  199.     OPCODE_INIT_NAMES,
  200.     OPCODE_LIGHT,
  201.     OPCODE_LIGHT_MODEL,
  202.     OPCODE_LINE_STIPPLE,
  203.     OPCODE_LINE_WIDTH,
  204.     OPCODE_LIST_BASE,
  205.     OPCODE_LOAD_IDENTITY,
  206.     OPCODE_LOAD_MATRIX,
  207.     OPCODE_LOAD_NAME,
  208.     OPCODE_LOGIC_OP,
  209.     OPCODE_MAP1,
  210.     OPCODE_MAP2,
  211.     OPCODE_MAPGRID1,
  212.     OPCODE_MAPGRID2,
  213.     OPCODE_MATERIAL,
  214.     OPCODE_MATRIX_MODE,
  215.     OPCODE_MULT_MATRIX,
  216.     OPCODE_MULTI_TEXCOORD4,
  217.         OPCODE_NORMAL,
  218.     OPCODE_ORTHO,
  219.     OPCODE_PASSTHROUGH,
  220.     OPCODE_PIXEL_MAP,
  221.     OPCODE_PIXEL_TRANSFER,
  222.     OPCODE_PIXEL_ZOOM,
  223.     OPCODE_POINT_SIZE,
  224.         OPCODE_POINT_PARAMETERS,
  225.     OPCODE_POLYGON_MODE,
  226.         OPCODE_POLYGON_STIPPLE,
  227.     OPCODE_POLYGON_OFFSET,
  228.     OPCODE_POP_ATTRIB,
  229.     OPCODE_POP_MATRIX,
  230.     OPCODE_POP_NAME,
  231.     OPCODE_PRIORITIZE_TEXTURE,
  232.     OPCODE_PUSH_ATTRIB,
  233.     OPCODE_PUSH_MATRIX,
  234.     OPCODE_PUSH_NAME,
  235.     OPCODE_RASTER_POS,
  236.     OPCODE_RECTF,
  237.     OPCODE_READ_BUFFER,
  238.         OPCODE_SCALE,
  239.     OPCODE_SCISSOR,
  240.     OPCODE_SELECT_TEXTURE_SGIS,
  241.     OPCODE_SELECT_TEXTURE,
  242.     OPCODE_SELECT_TEXTURE_COORD_SET,
  243.     OPCODE_SELECT_TEXTURE_TRANSFORM,
  244.     OPCODE_SHADE_MODEL,
  245.     OPCODE_STENCIL_FUNC,
  246.     OPCODE_STENCIL_MASK,
  247.     OPCODE_STENCIL_OP,
  248.     OPCODE_TEXCOORD2,
  249.     OPCODE_TEXCOORD4,
  250.         OPCODE_TEXENV,
  251.         OPCODE_TEXGEN,
  252.         OPCODE_TEXPARAMETER,
  253.     OPCODE_TEX_IMAGE1D,
  254.     OPCODE_TEX_IMAGE2D,
  255.     OPCODE_TEX_IMAGE3D,
  256.     OPCODE_TEX_SUB_IMAGE1D,
  257.     OPCODE_TEX_SUB_IMAGE2D,
  258.     OPCODE_TEX_SUB_IMAGE3D,
  259.         OPCODE_TRANSLATE,
  260.         OPCODE_VERTEX2,
  261.         OPCODE_VERTEX3,
  262.         OPCODE_VERTEX4,
  263.     OPCODE_VIEWPORT,
  264.     OPCODE_WINDOW_POS,
  265.     /* The following two are meta instructions */
  266.     OPCODE_CONTINUE,
  267.     OPCODE_END_OF_LIST
  268. } OpCode;
  269.  
  270.  
  271. /*
  272.  * Each instruction in the display list is stored as a sequence of
  273.  * contiguous nodes in memory.
  274.  * Each node is the union of a variety of datatypes.
  275.  */
  276. union node {
  277.     OpCode        opcode;
  278.     GLboolean    b;
  279.     GLbitfield    bf;
  280.     GLubyte        ub;
  281.     GLshort        s;
  282.     GLushort    us;
  283.     GLint        i;
  284.     GLuint        ui;
  285.     GLenum        e;
  286.     GLfloat        f;
  287.     GLvoid        *data;
  288.     void        *next;    /* If prev node's opcode==OPCODE_CONTINUE */
  289. };
  290.  
  291.  
  292.  
  293. /* Number of nodes of storage needed for each instruction: */
  294. static GLuint InstSize[ OPCODE_END_OF_LIST+1 ];
  295.  
  296.  
  297.  
  298. /**********************************************************************/
  299. /*****                           Private                          *****/
  300. /**********************************************************************/
  301.  
  302.  
  303. /*
  304.  * Allocate space for a display list instruction.
  305.  * Input:  opcode - type of instruction
  306.  *         argcount - number of arguments following the instruction
  307.  * Return: pointer to first node in the instruction
  308.  */
  309. static Node *alloc_instruction( GLcontext *ctx, OpCode opcode, GLint argcount )
  310. {
  311.    Node *n, *newblock;
  312.    GLuint count = InstSize[opcode];
  313.  
  314.    assert( (GLint) count == argcount+1 );
  315.  
  316.    if (ctx->CurrentPos + count + 2 > BLOCK_SIZE) {
  317.       /* This block is full.  Allocate a new block and chain to it */
  318.       n = ctx->CurrentBlock + ctx->CurrentPos;
  319.       n[0].opcode = OPCODE_CONTINUE;
  320.       newblock = (Node *) malloc( sizeof(Node) * BLOCK_SIZE );
  321.       if (!newblock) {
  322.          gl_error( ctx, GL_OUT_OF_MEMORY, "Building display list" );
  323.          return NULL;
  324.       }
  325.       n[1].next = (Node *) newblock;
  326.       ctx->CurrentBlock = newblock;
  327.       ctx->CurrentPos = 0;
  328.    }
  329.  
  330.    n = ctx->CurrentBlock + ctx->CurrentPos;
  331.    ctx->CurrentPos += count;
  332.  
  333.    n[0].opcode = opcode;
  334.  
  335.    return n;
  336. }
  337.  
  338.  
  339.  
  340. /*
  341.  * Make an empty display list.  This is used by glGenLists() to
  342.  * reserver display list IDs.
  343.  */
  344. static Node *make_empty_list( void )
  345. {
  346.    Node *n = (Node *) malloc( sizeof(Node) );
  347.    n[0].opcode = OPCODE_END_OF_LIST;
  348.    return n;
  349. }
  350.  
  351.  
  352.  
  353. /*
  354.  * Destroy all nodes in a display list.
  355.  * Input:  list - display list number
  356.  */
  357. void gl_destroy_list( GLcontext *ctx, GLuint list )
  358. {
  359.    Node *n, *block;
  360.    GLboolean done;
  361.  
  362.    block = (Node *) HashLookup(ctx->Shared->DisplayList, list);
  363.    n = block;
  364.  
  365.    done = block ? GL_FALSE : GL_TRUE;
  366.    while (!done) {
  367.       switch (n[0].opcode) {
  368.      /* special cases first */
  369.      case OPCODE_MAP1:
  370.         gl_free_control_points( ctx, n[1].e, (GLfloat *) n[6].data );
  371.         n += InstSize[n[0].opcode];
  372.         break;
  373.      case OPCODE_MAP2:
  374.         gl_free_control_points( ctx, n[1].e, (GLfloat *) n[10].data );
  375.         n += InstSize[n[0].opcode];
  376.         break;
  377.      case OPCODE_DRAW_PIXELS:
  378.         gl_free_image( (struct gl_image *) n[1].data );
  379.         n += InstSize[n[0].opcode];
  380.         break;
  381.      case OPCODE_BITMAP:
  382.         gl_free_image( (struct gl_image *) n[7].data );
  383.         n += InstSize[n[0].opcode];
  384.         break;
  385.          case OPCODE_COLOR_TABLE:
  386.             gl_free_image( (struct gl_image *) n[3].data );
  387.             n += InstSize[n[0].opcode];
  388.             break;
  389.          case OPCODE_COLOR_SUB_TABLE:
  390.             gl_free_image( (struct gl_image *) n[3].data );
  391.             n += InstSize[n[0].opcode];
  392.             break;
  393.          case OPCODE_POLYGON_STIPPLE:
  394.             free( n[1].data );
  395.         n += InstSize[n[0].opcode];
  396.             break;
  397.      case OPCODE_TEX_IMAGE1D:
  398.             gl_free_image( (struct gl_image *) n[8].data );
  399.             n += InstSize[n[0].opcode];
  400.         break;
  401.      case OPCODE_TEX_IMAGE2D:
  402.             gl_free_image( (struct gl_image *) n[9].data );
  403.             n += InstSize[n[0].opcode];
  404.         break;
  405.          case OPCODE_TEX_SUB_IMAGE1D:
  406.             {
  407.                struct gl_image *image;
  408.                image = (struct gl_image *) n[7].data;
  409.                gl_free_image( image );
  410.             }
  411.             break;
  412.          case OPCODE_TEX_SUB_IMAGE2D:
  413.             {
  414.                struct gl_image *image;
  415.                image = (struct gl_image *) n[9].data;
  416.                gl_free_image( image );
  417.             }
  418.             break;
  419.      case OPCODE_CONTINUE:
  420.         n = (Node *) n[1].next;
  421.         free( block );
  422.         block = n;
  423.         break;
  424.      case OPCODE_END_OF_LIST:
  425.         free( block );
  426.         done = GL_TRUE;
  427.         break;
  428.      default:
  429.         /* Most frequent case */
  430.         n += InstSize[n[0].opcode];
  431.         break;
  432.       }
  433.    }
  434.  
  435.    HashRemove(ctx->Shared->DisplayList, list);
  436. }
  437.  
  438.  
  439.  
  440. /*
  441.  * Translate the nth element of list from type to GLuint.
  442.  */
  443. static GLuint translate_id( GLsizei n, GLenum type, const GLvoid *list )
  444. {
  445.    GLbyte *bptr;
  446.    GLubyte *ubptr;
  447.    GLshort *sptr;
  448.    GLushort *usptr;
  449.    GLint *iptr;
  450.    GLuint *uiptr;
  451.    GLfloat *fptr;
  452.  
  453.    switch (type) {
  454.       case GL_BYTE:
  455.          bptr = (GLbyte *) list;
  456.          return (GLuint) *(bptr+n);
  457.       case GL_UNSIGNED_BYTE:
  458.          ubptr = (GLubyte *) list;
  459.          return (GLuint) *(ubptr+n);
  460.       case GL_SHORT:
  461.          sptr = (GLshort *) list;
  462.          return (GLuint) *(sptr+n);
  463.       case GL_UNSIGNED_SHORT:
  464.          usptr = (GLushort *) list;
  465.          return (GLuint) *(usptr+n);
  466.       case GL_INT:
  467.          iptr = (GLint *) list;
  468.          return (GLuint) *(iptr+n);
  469.       case GL_UNSIGNED_INT:
  470.          uiptr = (GLuint *) list;
  471.          return (GLuint) *(uiptr+n);
  472.       case GL_FLOAT:
  473.          fptr = (GLfloat *) list;
  474.          return (GLuint) *(fptr+n);
  475.       case GL_2_BYTES:
  476.          ubptr = ((GLubyte *) list) + 2*n;
  477.          return (GLuint) *ubptr * 256 + (GLuint) *(ubptr+1);
  478.       case GL_3_BYTES:
  479.          ubptr = ((GLubyte *) list) + 3*n;
  480.          return (GLuint) *ubptr * 65536
  481.               + (GLuint) *(ubptr+1) * 256
  482.               + (GLuint) *(ubptr+2);
  483.       case GL_4_BYTES:
  484.          ubptr = ((GLubyte *) list) + 4*n;
  485.          return (GLuint) *ubptr * 16777216
  486.               + (GLuint) *(ubptr+1) * 65536
  487.               + (GLuint) *(ubptr+2) * 256
  488.               + (GLuint) *(ubptr+3);
  489.       default:
  490.          return 0;
  491.    }
  492. }
  493.  
  494.  
  495.  
  496.  
  497. /**********************************************************************/
  498. /*****                        Public                              *****/
  499. /**********************************************************************/
  500.  
  501. void gl_init_lists( void )
  502. {
  503.    static int init_flag = 0;
  504.  
  505.    if (init_flag==0) {
  506.       InstSize[OPCODE_ACCUM] = 3;
  507.       InstSize[OPCODE_ALPHA_FUNC] = 3;
  508.       InstSize[OPCODE_BEGIN] = 2;
  509.       InstSize[OPCODE_BIND_TEXTURE] = 3;
  510.       InstSize[OPCODE_BITMAP] = 8;
  511.       InstSize[OPCODE_BLEND_COLOR] = 5;
  512.       InstSize[OPCODE_BLEND_EQUATION] = 2;
  513.       InstSize[OPCODE_BLEND_FUNC] = 3;
  514.       InstSize[OPCODE_CALL_LIST] = 2;
  515.       InstSize[OPCODE_CALL_LIST_OFFSET] = 2;
  516.       InstSize[OPCODE_CLEAR] = 2;
  517.       InstSize[OPCODE_CLEAR_ACCUM] = 5;
  518.       InstSize[OPCODE_CLEAR_COLOR] = 5;
  519.       InstSize[OPCODE_CLEAR_DEPTH] = 2;
  520.       InstSize[OPCODE_CLEAR_INDEX] = 2;
  521.       InstSize[OPCODE_CLEAR_STENCIL] = 2;
  522.       InstSize[OPCODE_CLIP_PLANE] = 6;
  523.       InstSize[OPCODE_COLOR_3F] = 4;
  524.       InstSize[OPCODE_COLOR_4F] = 5;
  525.       InstSize[OPCODE_COLOR_4UB] = 5;
  526.       InstSize[OPCODE_COLOR_MASK] = 5;
  527.       InstSize[OPCODE_COLOR_MATERIAL] = 3;
  528.       InstSize[OPCODE_COLOR_TABLE] = 4;
  529.       InstSize[OPCODE_COLOR_SUB_TABLE] = 4;
  530.       InstSize[OPCODE_COPY_PIXELS] = 6;
  531.       InstSize[OPCODE_COPY_TEX_IMAGE1D] = 8;
  532.       InstSize[OPCODE_COPY_TEX_IMAGE2D] = 9;
  533.       InstSize[OPCODE_COPY_TEX_SUB_IMAGE1D] = 7;
  534.       InstSize[OPCODE_COPY_TEX_SUB_IMAGE2D] = 9;
  535.       InstSize[OPCODE_COPY_TEX_SUB_IMAGE3D] = 10;
  536.       InstSize[OPCODE_CULL_FACE] = 2;
  537.       InstSize[OPCODE_DEPTH_FUNC] = 2;
  538.       InstSize[OPCODE_DEPTH_MASK] = 2;
  539.       InstSize[OPCODE_DEPTH_RANGE] = 3;
  540.       InstSize[OPCODE_DISABLE] = 2;
  541.       InstSize[OPCODE_DRAW_BUFFER] = 2;
  542.       InstSize[OPCODE_DRAW_PIXELS] = 2;
  543.       InstSize[OPCODE_ENABLE] = 2;
  544.       InstSize[OPCODE_EDGE_FLAG] = 2;
  545.       InstSize[OPCODE_END] = 1;
  546.       InstSize[OPCODE_EVALCOORD1] = 2;
  547.       InstSize[OPCODE_EVALCOORD2] = 3;
  548.       InstSize[OPCODE_EVALMESH1] = 4;
  549.       InstSize[OPCODE_EVALMESH2] = 6;
  550.       InstSize[OPCODE_EVALPOINT1] = 2;
  551.       InstSize[OPCODE_EVALPOINT2] = 3;
  552.       InstSize[OPCODE_FOG] = 6;
  553.       InstSize[OPCODE_FRONT_FACE] = 2;
  554.       InstSize[OPCODE_FRUSTUM] = 7;
  555.       InstSize[OPCODE_HINT] = 3;
  556.       InstSize[OPCODE_INDEX] = 2;
  557.       InstSize[OPCODE_INDEX_MASK] = 2;
  558.       InstSize[OPCODE_INIT_NAMES] = 1;
  559.       InstSize[OPCODE_LIGHT] = 7;
  560.       InstSize[OPCODE_LIGHT_MODEL] = 6;
  561.       InstSize[OPCODE_LINE_STIPPLE] = 3;
  562.       InstSize[OPCODE_LINE_WIDTH] = 2;
  563.       InstSize[OPCODE_LIST_BASE] = 2;
  564.       InstSize[OPCODE_LOAD_IDENTITY] = 1;
  565.       InstSize[OPCODE_LOAD_MATRIX] = 17;
  566.       InstSize[OPCODE_LOAD_NAME] = 2;
  567.       InstSize[OPCODE_LOGIC_OP] = 2;
  568.       InstSize[OPCODE_MAP1] = 7;
  569.       InstSize[OPCODE_MAP2] = 11;
  570.       InstSize[OPCODE_MAPGRID1] = 4;
  571.       InstSize[OPCODE_MAPGRID2] = 7;
  572.       InstSize[OPCODE_MATERIAL] = 7;
  573.       InstSize[OPCODE_MATRIX_MODE] = 2;
  574.       InstSize[OPCODE_MULT_MATRIX] = 17;
  575.       InstSize[OPCODE_MULTI_TEXCOORD4] = 6;
  576.       InstSize[OPCODE_NORMAL] = 4;
  577.       InstSize[OPCODE_ORTHO] = 7;
  578.       InstSize[OPCODE_PASSTHROUGH] = 2;
  579.       InstSize[OPCODE_PIXEL_MAP] = 4;
  580.       InstSize[OPCODE_PIXEL_TRANSFER] = 3;
  581.       InstSize[OPCODE_PIXEL_ZOOM] = 3;
  582.       InstSize[OPCODE_POINT_SIZE] = 2;
  583.       InstSize[OPCODE_POINT_PARAMETERS] = 5;
  584.       InstSize[OPCODE_POLYGON_MODE] = 3;
  585.       InstSize[OPCODE_POLYGON_STIPPLE] = 2;
  586.       InstSize[OPCODE_POLYGON_OFFSET] = 3;
  587.       InstSize[OPCODE_POP_ATTRIB] = 1;
  588.       InstSize[OPCODE_POP_MATRIX] = 1;
  589.       InstSize[OPCODE_POP_NAME] = 1;
  590.       InstSize[OPCODE_PRIORITIZE_TEXTURE] = 3;
  591.       InstSize[OPCODE_PUSH_ATTRIB] = 2;
  592.       InstSize[OPCODE_PUSH_MATRIX] = 1;
  593.       InstSize[OPCODE_PUSH_NAME] = 2;
  594.       InstSize[OPCODE_RASTER_POS] = 5;
  595.       InstSize[OPCODE_RECTF] = 5;
  596.       InstSize[OPCODE_READ_BUFFER] = 2;
  597.       InstSize[OPCODE_SCALE] = 4;
  598.       InstSize[OPCODE_SCISSOR] = 5;
  599.       InstSize[OPCODE_SELECT_TEXTURE_SGIS] = 2;
  600.       InstSize[OPCODE_SELECT_TEXTURE] = 2;
  601.       InstSize[OPCODE_SELECT_TEXTURE_COORD_SET] = 2;
  602.       InstSize[OPCODE_SELECT_TEXTURE_TRANSFORM] = 2;
  603.       InstSize[OPCODE_STENCIL_FUNC] = 4;
  604.       InstSize[OPCODE_STENCIL_MASK] = 2;
  605.       InstSize[OPCODE_STENCIL_OP] = 4;
  606.       InstSize[OPCODE_SHADE_MODEL] = 2;
  607.       InstSize[OPCODE_TEXCOORD2] = 3;
  608.       InstSize[OPCODE_TEXCOORD4] = 5;
  609.       InstSize[OPCODE_TEXENV] = 7;
  610.       InstSize[OPCODE_TEXGEN] = 7;
  611.       InstSize[OPCODE_TEXPARAMETER] = 7;
  612.       InstSize[OPCODE_TEX_IMAGE1D] = 9;
  613.       InstSize[OPCODE_TEX_IMAGE2D] = 10;
  614.       InstSize[OPCODE_TEX_IMAGE3D] = 11;
  615.       InstSize[OPCODE_TEX_SUB_IMAGE1D] = 8;
  616.       InstSize[OPCODE_TEX_SUB_IMAGE2D] = 10;
  617.       InstSize[OPCODE_TEX_SUB_IMAGE3D] = 12;
  618.       InstSize[OPCODE_TRANSLATE] = 4;
  619.       InstSize[OPCODE_VERTEX2] = 3;
  620.       InstSize[OPCODE_VERTEX3] = 4;
  621.       InstSize[OPCODE_VERTEX4] = 5;
  622.       InstSize[OPCODE_VIEWPORT] = 5;
  623.       InstSize[OPCODE_WINDOW_POS] = 5;
  624.       InstSize[OPCODE_CONTINUE] = 2;
  625.       InstSize[OPCODE_END_OF_LIST] = 1;
  626.    }
  627.    init_flag = 1;
  628. }
  629.  
  630.  
  631. /*
  632.  * Display List compilation functions
  633.  */
  634.  
  635.  
  636. void gl_save_Accum( GLcontext *ctx, GLenum op, GLfloat value )
  637. {
  638.    Node *n = alloc_instruction( ctx, OPCODE_ACCUM, 2 );
  639.    if (n) {
  640.       n[1].e = op;
  641.       n[2].f = value;
  642.    }
  643.    if (ctx->ExecuteFlag) {
  644.       (*ctx->Exec.Accum)( ctx, op, value );
  645.    }
  646. }
  647.  
  648.  
  649. void gl_save_AlphaFunc( GLcontext *ctx, GLenum func, GLclampf ref )
  650. {
  651.    Node *n = alloc_instruction( ctx, OPCODE_ALPHA_FUNC, 2 );
  652.    if (n) {
  653.       n[1].e = func;
  654.       n[2].f = (GLfloat) ref;
  655.    }
  656.    if (ctx->ExecuteFlag) {
  657.       (*ctx->Exec.AlphaFunc)( ctx, func, ref );
  658.    }
  659. }
  660.  
  661.  
  662. void gl_save_Begin( GLcontext *ctx, GLenum mode )
  663. {
  664.    Node *n = alloc_instruction( ctx, OPCODE_BEGIN, 1 );
  665.    if (n) {
  666.       n[1].e = mode;
  667.    }
  668.    if (ctx->ExecuteFlag) {
  669.       (*ctx->Exec.Begin)( ctx, mode );
  670.    }
  671. }
  672.  
  673.  
  674. void gl_save_BindTexture( GLcontext *ctx, GLenum target, GLuint texture )
  675. {
  676.    Node *n = alloc_instruction( ctx, OPCODE_BIND_TEXTURE, 2 );
  677.    if (n) {
  678.       n[1].e = target;
  679.       n[2].ui = texture;
  680.    }
  681.    if (ctx->ExecuteFlag) {
  682.       (*ctx->Exec.BindTexture)( ctx, target, texture );
  683.    }
  684. }
  685.  
  686.  
  687. void gl_save_Bitmap( GLcontext *ctx,
  688.                      GLsizei width, GLsizei height,
  689.              GLfloat xorig, GLfloat yorig,
  690.              GLfloat xmove, GLfloat ymove,
  691.              struct gl_image *bitmap )
  692. {
  693.    Node *n = alloc_instruction( ctx, OPCODE_BITMAP, 7 );
  694.    if (n) {
  695.       n[1].i = (GLint) width;
  696.       n[2].i = (GLint) height;
  697.       n[3].f = xorig;
  698.       n[4].f = yorig;
  699.       n[5].f = xmove;
  700.       n[6].f = ymove;
  701.       n[7].data = (void *) bitmap;
  702.    }
  703.    if (bitmap) {
  704.       bitmap->RefCount = 1;
  705.    }
  706.    if (ctx->ExecuteFlag) {
  707.       (*ctx->Exec.Bitmap)( ctx, width, height,
  708.                     xorig, yorig, xmove, ymove, bitmap );
  709.    }
  710. }
  711.  
  712.  
  713. void gl_save_BlendEquation( GLcontext *ctx, GLenum mode )
  714. {
  715.    Node *n = alloc_instruction( ctx, OPCODE_BLEND_EQUATION, 1 );
  716.    if (n) {
  717.       n[1].e = mode;
  718.    }
  719.    if (ctx->ExecuteFlag) {
  720.       (*ctx->Exec.BlendEquation)( ctx, mode );
  721.    }
  722. }
  723.  
  724.  
  725. void gl_save_BlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor )
  726. {
  727.    Node *n = alloc_instruction( ctx, OPCODE_BLEND_FUNC, 2 );
  728.    if (n) {
  729.       n[1].e = sfactor;
  730.       n[2].e = dfactor;
  731.    }
  732.    if (ctx->ExecuteFlag) {
  733.       (*ctx->Exec.BlendFunc)( ctx, sfactor, dfactor );
  734.    }
  735. }
  736.  
  737.  
  738. void gl_save_BlendColor( GLcontext *ctx, GLfloat red, GLfloat green,
  739.                          GLfloat blue, GLfloat alpha )
  740. {
  741.    Node *n = alloc_instruction( ctx, OPCODE_BLEND_COLOR, 4 );
  742.    if (n) {
  743.       n[1].f = red;
  744.       n[2].f = green;
  745.       n[3].f = blue;
  746.       n[4].f = alpha;
  747.    }
  748.    if (ctx->ExecuteFlag) {
  749.       (*ctx->Exec.BlendColor)( ctx, red, green, blue, alpha );
  750.    }
  751. }
  752.  
  753.  
  754. void gl_save_CallList( GLcontext *ctx, GLuint list )
  755. {
  756.    Node *n = alloc_instruction( ctx, OPCODE_CALL_LIST, 1 );
  757.    if (n) {
  758.       n[1].ui = list;
  759.    }
  760.    if (ctx->ExecuteFlag) {
  761.       (*ctx->Exec.CallList)( ctx, list );
  762.    }
  763. }
  764.  
  765.  
  766. void gl_save_CallLists( GLcontext *ctx,
  767.                         GLsizei n, GLenum type, const GLvoid *lists )
  768. {
  769.    GLint i;
  770.  
  771.    for (i=0;i<n;i++) {
  772.       GLuint list = translate_id( i, type, lists );
  773.       Node *n = alloc_instruction( ctx, OPCODE_CALL_LIST_OFFSET, 1 );
  774.       if (n) {
  775.          n[1].ui = list;
  776.       }
  777.    }
  778.    if (ctx->ExecuteFlag) {
  779.       (*ctx->Exec.CallLists)( ctx, n, type, lists );
  780.    }
  781. }
  782.  
  783.  
  784. void gl_save_Clear( GLcontext *ctx, GLbitfield mask )
  785. {
  786.    Node *n = alloc_instruction( ctx, OPCODE_CLEAR, 1 );
  787.    if (n) {
  788.       n[1].bf = mask;
  789.    }
  790.    if (ctx->ExecuteFlag) {
  791.       (*ctx->Exec.Clear)( ctx, mask );
  792.    }
  793. }
  794.  
  795.  
  796. void gl_save_ClearAccum( GLcontext *ctx, GLfloat red, GLfloat green,
  797.              GLfloat blue, GLfloat alpha )
  798. {
  799.    Node *n = alloc_instruction( ctx, OPCODE_CLEAR_ACCUM, 4 );
  800.    if (n) {
  801.       n[1].f = red;
  802.       n[2].f = green;
  803.       n[3].f = blue;
  804.       n[4].f = alpha;
  805.    }
  806.    if (ctx->ExecuteFlag) {
  807.       (*ctx->Exec.ClearAccum)( ctx, red, green, blue, alpha );
  808.    }
  809. }
  810.  
  811.  
  812. void gl_save_ClearColor( GLcontext *ctx, GLclampf red, GLclampf green,
  813.              GLclampf blue, GLclampf alpha )
  814. {
  815.    Node *n = alloc_instruction( ctx, OPCODE_CLEAR_COLOR, 4 );
  816.    if (n) {
  817.       n[1].f = red;
  818.       n[2].f = green;
  819.       n[3].f = blue;
  820.       n[4].f = alpha;
  821.    }
  822.    if (ctx->ExecuteFlag) {
  823.       (*ctx->Exec.ClearColor)( ctx, red, green, blue, alpha );
  824.    }
  825. }
  826.  
  827.  
  828. void gl_save_ClearDepth( GLcontext *ctx, GLclampd depth )
  829. {
  830.    Node *n = alloc_instruction( ctx, OPCODE_CLEAR_DEPTH, 1 );
  831.    if (n) {
  832.       n[1].f = (GLfloat) depth;
  833.    }
  834.    if (ctx->ExecuteFlag) {
  835.       (*ctx->Exec.ClearDepth)( ctx, depth );
  836.    }
  837. }
  838.  
  839.  
  840. void gl_save_ClearIndex( GLcontext *ctx, GLfloat c )
  841. {
  842.    Node *n = alloc_instruction( ctx, OPCODE_CLEAR_INDEX, 1 );
  843.    if (n) {
  844.       n[1].f = c;
  845.    }
  846.    if (ctx->ExecuteFlag) {
  847.       (*ctx->Exec.ClearIndex)( ctx, c );
  848.    }
  849. }
  850.  
  851.  
  852. void gl_save_ClearStencil( GLcontext *ctx, GLint s )
  853. {
  854.    Node *n = alloc_instruction( ctx, OPCODE_CLEAR_STENCIL, 1 );
  855.    if (n) {
  856.       n[1].i = s;
  857.    }
  858.    if (ctx->ExecuteFlag) {
  859.       (*ctx->Exec.ClearStencil)( ctx, s );
  860.    }
  861. }
  862.  
  863.  
  864. void gl_save_ClipPlane( GLcontext *ctx, GLenum plane, const GLfloat *equ )
  865. {
  866.    Node *n = alloc_instruction( ctx, OPCODE_CLIP_PLANE, 5 );
  867.    if (n) {
  868.       n[1].e = plane;
  869.       n[2].f = equ[0];
  870.       n[3].f = equ[1];
  871.       n[4].f = equ[2];
  872.       n[5].f = equ[3];
  873.    }
  874.    if (ctx->ExecuteFlag) {
  875.       (*ctx->Exec.ClipPlane)( ctx, plane, equ );
  876.    }
  877. }
  878.  
  879.  
  880. void gl_save_Color3f( GLcontext *ctx, GLfloat r, GLfloat g, GLfloat b )
  881. {
  882.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_3F, 3 );
  883.    if (n) {
  884.       n[1].f = r;
  885.       n[2].f = g;
  886.       n[3].f = b;
  887.    }
  888.    if (ctx->ExecuteFlag) {
  889.       (*ctx->Exec.Color3f)( ctx, r, g, b );
  890.    }
  891. }
  892.  
  893.  
  894. void gl_save_Color3fv( GLcontext *ctx, const GLfloat *c )
  895. {
  896.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_3F, 3 );
  897.    if (n) {
  898.       n[1].f = c[0];
  899.       n[2].f = c[1];
  900.       n[3].f = c[2];
  901.    }
  902.    if (ctx->ExecuteFlag) {
  903.       (*ctx->Exec.Color3fv)( ctx, c );
  904.    }
  905. }
  906.  
  907.  
  908. void gl_save_Color4f( GLcontext *ctx, GLfloat r, GLfloat g,
  909.                                       GLfloat b, GLfloat a )
  910. {
  911.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_4F, 4 );
  912.    if (n) {
  913.       n[1].f = r;
  914.       n[2].f = g;
  915.       n[3].f = b;
  916.       n[4].f = a;
  917.    }
  918.    if (ctx->ExecuteFlag) {
  919.       (*ctx->Exec.Color4f)( ctx, r, g, b, a );
  920.    }
  921. }
  922.  
  923.  
  924. void gl_save_Color4fv( GLcontext *ctx, const GLfloat *c )
  925. {
  926.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_4F, 4 );
  927.    if (n) {
  928.       n[1].f = c[0];
  929.       n[2].f = c[1];
  930.       n[3].f = c[2];
  931.       n[4].f = c[3];
  932.    }
  933.    if (ctx->ExecuteFlag) {
  934.       (*ctx->Exec.Color4fv)( ctx, c );
  935.    }
  936. }
  937.  
  938.  
  939. void gl_save_Color4ub( GLcontext *ctx, GLubyte r, GLubyte g,
  940.                                        GLubyte b, GLubyte a )
  941. {
  942.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_4UB, 4 );
  943.    if (n) {
  944.       n[1].ub = r;
  945.       n[2].ub = g;
  946.       n[3].ub = b;
  947.       n[4].ub = a;
  948.    }
  949.    if (ctx->ExecuteFlag) {
  950.       (*ctx->Exec.Color4ub)( ctx, r, g, b, a );
  951.    }
  952. }
  953.  
  954.  
  955. void gl_save_Color4ubv( GLcontext *ctx, const GLubyte *c )
  956. {
  957.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_4UB, 4 );
  958.    if (n) {
  959.       n[1].ub = c[0];
  960.       n[2].ub = c[1];
  961.       n[3].ub = c[2];
  962.       n[4].ub = c[3];
  963.    }
  964.    if (ctx->ExecuteFlag) {
  965.       (*ctx->Exec.Color4ubv)( ctx, c );
  966.    }
  967. }
  968.  
  969.  
  970. void gl_save_ColorMask( GLcontext *ctx, GLboolean red, GLboolean green,
  971.                         GLboolean blue, GLboolean alpha )
  972. {
  973.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_MASK, 4 );
  974.    if (n) {
  975.       n[1].b = red;
  976.       n[2].b = green;
  977.       n[3].b = blue;
  978.       n[4].b = alpha;
  979.    }
  980.    if (ctx->ExecuteFlag) {
  981.       (*ctx->Exec.ColorMask)( ctx, red, green, blue, alpha );
  982.    }
  983. }
  984.  
  985.  
  986. void gl_save_ColorMaterial( GLcontext *ctx, GLenum face, GLenum mode )
  987. {
  988.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_MATERIAL, 2 );
  989.    if (n) {
  990.       n[1].e = face;
  991.       n[2].e = mode;
  992.    }
  993.    if (ctx->ExecuteFlag) {
  994.       (*ctx->Exec.ColorMaterial)( ctx, face, mode );
  995.    }
  996. }
  997.  
  998.  
  999. void gl_save_ColorTable( GLcontext *ctx, GLenum target, GLenum internalFormat,
  1000.                          struct gl_image *table )
  1001. {
  1002.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_TABLE, 3 );
  1003.    if (n) {
  1004.       n[1].e = target;
  1005.       n[2].e = internalFormat;
  1006.       n[3].data = (GLvoid *) table;
  1007.       if (table) {
  1008.          /* must retain this image */
  1009.          table->RefCount = 1;
  1010.       }
  1011.    }
  1012.    if (ctx->ExecuteFlag) {
  1013.       (*ctx->Exec.ColorTable)( ctx, target, internalFormat, table );
  1014.    }
  1015. }
  1016.  
  1017.  
  1018. void gl_save_ColorSubTable( GLcontext *ctx, GLenum target,
  1019.                             GLsizei start, struct gl_image *data )
  1020. {
  1021.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_SUB_TABLE, 3 );
  1022.    if (n) {
  1023.       n[1].e = target;
  1024.       n[2].i = start;
  1025.       n[3].data = (GLvoid *) data;
  1026.       if (data) {
  1027.          /* must retain this image */
  1028.          data->RefCount = 1;
  1029.       }
  1030.    }
  1031.    if (ctx->ExecuteFlag) {
  1032.       (*ctx->Exec.ColorSubTable)( ctx, target, start, data );
  1033.    }
  1034. }
  1035.  
  1036.  
  1037.  
  1038. void gl_save_CopyPixels( GLcontext *ctx, GLint x, GLint y,
  1039.              GLsizei width, GLsizei height, GLenum type )
  1040. {
  1041.    Node *n = alloc_instruction( ctx, OPCODE_COPY_PIXELS, 5 );
  1042.    if (n) {
  1043.       n[1].i = x;
  1044.       n[2].i = y;
  1045.       n[3].i = (GLint) width;
  1046.       n[4].i = (GLint) height;
  1047.       n[5].e = type;
  1048.    }
  1049.    if (ctx->ExecuteFlag) {
  1050.       (*ctx->Exec.CopyPixels)( ctx, x, y, width, height, type );
  1051.    }
  1052. }
  1053.  
  1054.  
  1055.  
  1056. void gl_save_CopyTexImage1D( GLcontext *ctx,
  1057.                              GLenum target, GLint level,
  1058.                              GLenum internalformat,
  1059.                              GLint x, GLint y, GLsizei width,
  1060.                              GLint border )
  1061. {
  1062.    Node *n = alloc_instruction( ctx, OPCODE_COPY_TEX_IMAGE1D, 7 );
  1063.    if (n) {
  1064.       n[1].e = target;
  1065.       n[2].i = level;
  1066.       n[3].e = internalformat;
  1067.       n[4].i = x;
  1068.       n[5].i = y;
  1069.       n[6].i = width;
  1070.       n[7].i = border;
  1071.    }
  1072.    if (ctx->ExecuteFlag) {
  1073.       (*ctx->Exec.CopyTexImage1D)( ctx, target, level, internalformat,
  1074.                             x, y, width, border );
  1075.    }
  1076. }
  1077.  
  1078.  
  1079. void gl_save_CopyTexImage2D( GLcontext *ctx,
  1080.                              GLenum target, GLint level,
  1081.                              GLenum internalformat,
  1082.                              GLint x, GLint y, GLsizei width,
  1083.                              GLsizei height, GLint border )
  1084. {
  1085.    Node *n = alloc_instruction( ctx, OPCODE_COPY_TEX_IMAGE2D, 8 );
  1086.    if (n) {
  1087.       n[1].e = target;
  1088.       n[2].i = level;
  1089.       n[3].e = internalformat;
  1090.       n[4].i = x;
  1091.       n[5].i = y;
  1092.       n[6].i = width;
  1093.       n[7].i = height;
  1094.       n[8].i = border;
  1095.    }
  1096.    if (ctx->ExecuteFlag) {
  1097.       (*ctx->Exec.CopyTexImage2D)( ctx, target, level, internalformat,
  1098.                             x, y, width, height, border );
  1099.    }
  1100. }
  1101.  
  1102.  
  1103.  
  1104. void gl_save_CopyTexSubImage1D( GLcontext *ctx,
  1105.                                 GLenum target, GLint level,
  1106.                                 GLint xoffset, GLint x, GLint y,
  1107.                                 GLsizei width )
  1108. {
  1109.    Node *n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6 );
  1110.    if (n) {
  1111.       n[1].e = target;
  1112.       n[2].i = level;
  1113.       n[3].i = xoffset;
  1114.       n[4].i = x;
  1115.       n[5].i = y;
  1116.       n[6].i = width;
  1117.    }
  1118.    if (ctx->ExecuteFlag) {
  1119.       (*ctx->Exec.CopyTexSubImage1D)( ctx, target, level, xoffset, x, y, width );
  1120.    }
  1121. }
  1122.  
  1123.  
  1124. void gl_save_CopyTexSubImage2D( GLcontext *ctx,
  1125.                                 GLenum target, GLint level,
  1126.                                 GLint xoffset, GLint yoffset,
  1127.                                 GLint x, GLint y,
  1128.                                 GLsizei width, GLint height )
  1129. {
  1130.    Node *n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8 );
  1131.    if (n) {
  1132.       n[1].e = target;
  1133.       n[2].i = level;
  1134.       n[3].i = xoffset;
  1135.       n[4].i = yoffset;
  1136.       n[5].i = x;
  1137.       n[6].i = y;
  1138.       n[7].i = width;
  1139.       n[8].i = height;
  1140.    }
  1141.    if (ctx->ExecuteFlag) {
  1142.       (*ctx->Exec.CopyTexSubImage2D)( ctx, target, level, xoffset, yoffset,
  1143.                                x, y, width, height );
  1144.    }
  1145. }
  1146.  
  1147.  
  1148. void gl_save_CopyTexSubImage3DEXT( GLcontext *ctx,
  1149.                                    GLenum target, GLint level,
  1150.                                    GLint xoffset, GLint yoffset, GLint zoffset,
  1151.                                    GLint x, GLint y,
  1152.                                    GLsizei width, GLint height )
  1153. {
  1154.    Node *n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9 );
  1155.    if (n) {
  1156.       n[1].e = target;
  1157.       n[2].i = level;
  1158.       n[3].i = xoffset;
  1159.       n[4].i = yoffset;
  1160.       n[5].i = zoffset;
  1161.       n[6].i = x;
  1162.       n[7].i = y;
  1163.       n[8].i = width;
  1164.       n[9].i = height;
  1165.    }
  1166.    if (ctx->ExecuteFlag) {
  1167.       (*ctx->Exec.CopyTexSubImage3DEXT)( ctx, target, level, xoffset, yoffset, zoffset,
  1168.                                x, y, width, height );
  1169.    }
  1170. }
  1171.  
  1172.  
  1173. void gl_save_CullFace( GLcontext *ctx, GLenum mode )
  1174. {
  1175.    Node *n = alloc_instruction( ctx, OPCODE_CULL_FACE, 1 );
  1176.    if (n) {
  1177.       n[1].e = mode;
  1178.    }
  1179.    if (ctx->ExecuteFlag) {
  1180.       (*ctx->Exec.CullFace)( ctx, mode );
  1181.    }
  1182. }
  1183.  
  1184.  
  1185. void gl_save_DepthFunc( GLcontext *ctx, GLenum func )
  1186. {
  1187.    Node *n = alloc_instruction( ctx, OPCODE_DEPTH_FUNC, 1 );
  1188.    if (n) {
  1189.       n[1].e = func;
  1190.    }
  1191.    if (ctx->ExecuteFlag) {
  1192.       (*ctx->Exec.DepthFunc)( ctx, func );
  1193.    }
  1194. }
  1195.  
  1196.  
  1197. void gl_save_DepthMask( GLcontext *ctx, GLboolean mask )
  1198. {
  1199.    Node *n = alloc_instruction( ctx, OPCODE_DEPTH_MASK, 1 );
  1200.    if (n) {
  1201.       n[1].b = mask;
  1202.    }
  1203.    if (ctx->ExecuteFlag) {
  1204.       (*ctx->Exec.DepthMask)( ctx, mask );
  1205.    }
  1206. }
  1207.  
  1208.  
  1209. void gl_save_DepthRange( GLcontext *ctx, GLclampd nearval, GLclampd farval )
  1210. {
  1211.    Node *n = alloc_instruction( ctx, OPCODE_DEPTH_RANGE, 2 );
  1212.    if (n) {
  1213.       n[1].f = (GLfloat) nearval;
  1214.       n[2].f = (GLfloat) farval;
  1215.    }
  1216.    if (ctx->ExecuteFlag) {
  1217.       (*ctx->Exec.DepthRange)( ctx, nearval, farval );
  1218.    }
  1219. }
  1220.  
  1221.  
  1222. void gl_save_Disable( GLcontext *ctx, GLenum cap )
  1223. {
  1224.    Node *n = alloc_instruction( ctx, OPCODE_DISABLE, 1 );
  1225.    if (n) {
  1226.       n[1].e = cap;
  1227.    }
  1228.    if (ctx->ExecuteFlag) {
  1229.       (*ctx->Exec.Disable)( ctx, cap );
  1230.    }
  1231. }
  1232.  
  1233.  
  1234. void gl_save_DrawBuffer( GLcontext *ctx, GLenum mode )
  1235. {
  1236.    Node *n = alloc_instruction( ctx, OPCODE_DRAW_BUFFER, 1 );
  1237.    if (n) {
  1238.       n[1].e = mode;
  1239.    }
  1240.    if (ctx->ExecuteFlag) {
  1241.       (*ctx->Exec.DrawBuffer)( ctx, mode );
  1242.    }
  1243. }
  1244.  
  1245.  
  1246. void gl_save_DrawPixels( GLcontext *ctx, struct gl_image *image )
  1247. {
  1248.    Node *n = alloc_instruction( ctx, OPCODE_DRAW_PIXELS, 1 );
  1249.    if (n) {
  1250.       n[1].data = (GLvoid *) image;
  1251.    }
  1252.    if (image) {
  1253.       image->RefCount = 1;
  1254.    }
  1255.    if (ctx->ExecuteFlag) {
  1256.       (*ctx->Exec.DrawPixels)( ctx, image );
  1257.    }
  1258. }
  1259.  
  1260.  
  1261. void gl_save_EdgeFlag( GLcontext *ctx, GLboolean flag )
  1262. {
  1263.    Node *n = alloc_instruction( ctx, OPCODE_EDGE_FLAG, 1 );
  1264.    if (n) {
  1265.       n[1].b = flag;
  1266.    }
  1267.    if (ctx->ExecuteFlag) {
  1268.       (*ctx->Exec.EdgeFlag)( ctx, flag );
  1269.    }
  1270. }
  1271.  
  1272.  
  1273. void gl_save_Enable( GLcontext *ctx, GLenum cap )
  1274. {
  1275.    Node *n = alloc_instruction( ctx, OPCODE_ENABLE, 1 );
  1276.    if (n) {
  1277.       n[1].e = cap;
  1278.    }
  1279.    if (ctx->ExecuteFlag) {
  1280.       (*ctx->Exec.Enable)( ctx, cap );
  1281.    }
  1282. }
  1283.  
  1284.  
  1285. void gl_save_End( GLcontext *ctx )
  1286. {
  1287.    (void) alloc_instruction( ctx, OPCODE_END, 0 );
  1288.    if (ctx->ExecuteFlag) {
  1289.       (*ctx->Exec.End)( ctx );
  1290.    }
  1291. }
  1292.  
  1293.  
  1294. void gl_save_EvalCoord1f( GLcontext *ctx, GLfloat u )
  1295. {
  1296.    Node *n = alloc_instruction( ctx, OPCODE_EVALCOORD1, 1 );
  1297.    if (n) {
  1298.       n[1].f = u;
  1299.    }
  1300.    if (ctx->ExecuteFlag) {
  1301.       (*ctx->Exec.EvalCoord1f)( ctx, u );
  1302.    }
  1303. }
  1304.  
  1305.  
  1306. void gl_save_EvalCoord2f( GLcontext *ctx, GLfloat u, GLfloat v )
  1307. {
  1308.    Node *n = alloc_instruction( ctx, OPCODE_EVALCOORD2, 2 );
  1309.    if (n) {
  1310.       n[1].f = u;
  1311.       n[2].f = v;
  1312.    }
  1313.    if (ctx->ExecuteFlag) {
  1314.       (*ctx->Exec.EvalCoord2f)( ctx, u, v );
  1315.    }
  1316. }
  1317.  
  1318.  
  1319. void gl_save_EvalMesh1( GLcontext *ctx,
  1320.                         GLenum mode, GLint i1, GLint i2 )
  1321. {
  1322.    Node *n = alloc_instruction( ctx, OPCODE_EVALMESH1, 3 );
  1323.    if (n) {
  1324.       n[1].e = mode;
  1325.       n[2].i = i1;
  1326.       n[3].i = i2;
  1327.    }
  1328.    if (ctx->ExecuteFlag) {
  1329.       (*ctx->Exec.EvalMesh1)( ctx, mode, i1, i2 );
  1330.    }
  1331. }
  1332.  
  1333.  
  1334. void gl_save_EvalMesh2( GLcontext *ctx, 
  1335.                         GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
  1336. {
  1337.    Node *n = alloc_instruction( ctx, OPCODE_EVALMESH2, 5 );
  1338.    if (n) {
  1339.       n[1].e = mode;
  1340.       n[2].i = i1;
  1341.       n[3].i = i2;
  1342.       n[4].i = j1;
  1343.       n[5].i = j2;
  1344.    }
  1345.    if (ctx->ExecuteFlag) {
  1346.       (*ctx->Exec.EvalMesh2)( ctx, mode, i1, i2, j1, j2 );
  1347.    }
  1348. }
  1349.  
  1350.  
  1351. void gl_save_EvalPoint1( GLcontext *ctx, GLint i )
  1352. {
  1353.    Node *n = alloc_instruction( ctx, OPCODE_EVALPOINT1, 1 );
  1354.    if (n) {
  1355.       n[1].i = i;
  1356.    }
  1357.    if (ctx->ExecuteFlag) {
  1358.       (*ctx->Exec.EvalPoint1)( ctx, i );
  1359.    }
  1360. }
  1361.  
  1362.  
  1363. void gl_save_EvalPoint2( GLcontext *ctx, GLint i, GLint j )
  1364. {
  1365.    Node *n = alloc_instruction( ctx, OPCODE_EVALPOINT2, 2 );
  1366.    if (n) {
  1367.       n[1].i = i;
  1368.       n[2].i = j;
  1369.    }
  1370.    if (ctx->ExecuteFlag) {
  1371.       (*ctx->Exec.EvalPoint2)( ctx, i, j );
  1372.    }
  1373. }
  1374.  
  1375.  
  1376. void gl_save_Fogfv( GLcontext *ctx, GLenum pname, const GLfloat *params )
  1377. {
  1378.    Node *n = alloc_instruction( ctx, OPCODE_FOG, 5 );
  1379.    if (n) {
  1380.       n[1].e = pname;
  1381.       n[2].f = params[0];
  1382.       n[3].f = params[1];
  1383.       n[4].f = params[2];
  1384.       n[5].f = params[3];
  1385.    }
  1386.    if (ctx->ExecuteFlag) {
  1387.       (*ctx->Exec.Fogfv)( ctx, pname, params );
  1388.    }
  1389. }
  1390.  
  1391.  
  1392. void gl_save_FrontFace( GLcontext *ctx, GLenum mode )
  1393. {
  1394.    Node *n = alloc_instruction( ctx, OPCODE_FRONT_FACE, 1 );
  1395.    if (n) {
  1396.       n[1].e = mode;
  1397.    }
  1398.    if (ctx->ExecuteFlag) {
  1399.       (*ctx->Exec.FrontFace)( ctx, mode );
  1400.    }
  1401. }
  1402.  
  1403.  
  1404. void gl_save_Frustum( GLcontext *ctx, GLdouble left, GLdouble right,
  1405.                       GLdouble bottom, GLdouble top,
  1406.                       GLdouble nearval, GLdouble farval )
  1407. {
  1408.    Node *n = alloc_instruction( ctx, OPCODE_FRUSTUM, 6 );
  1409.    if (n) {
  1410.       n[1].f = left;
  1411.       n[2].f = right;
  1412.       n[3].f = bottom;
  1413.       n[4].f = top;
  1414.       n[5].f = nearval;
  1415.       n[6].f = farval;
  1416.    }
  1417.    if (ctx->ExecuteFlag) {
  1418.       (*ctx->Exec.Frustum)( ctx, left, right, bottom, top, nearval, farval );
  1419.    }
  1420. }
  1421.  
  1422.  
  1423. void gl_save_Hint( GLcontext *ctx, GLenum target, GLenum mode )
  1424. {
  1425.    Node *n = alloc_instruction( ctx, OPCODE_HINT, 2 );
  1426.    if (n) {
  1427.       n[1].e = target;
  1428.       n[2].e = mode;
  1429.    }
  1430.    if (ctx->ExecuteFlag) {
  1431.       (*ctx->Exec.Hint)( ctx, target, mode );
  1432.    }
  1433. }
  1434.  
  1435.  
  1436. void gl_save_Indexi( GLcontext *ctx, GLint index )
  1437. {
  1438.    Node *n = alloc_instruction( ctx, OPCODE_INDEX, 1 );
  1439.    if (n) {
  1440.       n[1].i = index;
  1441.    }
  1442.    if (ctx->ExecuteFlag) {
  1443.       (*ctx->Exec.Indexi)( ctx, index );
  1444.    }
  1445. }
  1446.  
  1447.  
  1448. void gl_save_Indexf( GLcontext *ctx, GLfloat index )
  1449. {
  1450.    Node *n = alloc_instruction( ctx, OPCODE_INDEX, 1 );
  1451.    if (n) {
  1452.       n[1].i = (GLint) index;
  1453.    }
  1454.    if (ctx->ExecuteFlag) {
  1455.       (*ctx->Exec.Indexf)( ctx,index );
  1456.    }
  1457. }
  1458.  
  1459.  
  1460. void gl_save_IndexMask( GLcontext *ctx, GLuint mask )
  1461. {
  1462.    Node *n = alloc_instruction( ctx, OPCODE_INDEX_MASK, 1 );
  1463.    if (n) {
  1464.       n[1].ui = mask;
  1465.    }
  1466.    if (ctx->ExecuteFlag) {
  1467.       (*ctx->Exec.IndexMask)( ctx, mask );
  1468.    }
  1469. }
  1470.  
  1471.  
  1472. void gl_save_InitNames( GLcontext *ctx )
  1473. {
  1474.    (void) alloc_instruction( ctx, OPCODE_INIT_NAMES, 0 );
  1475.    if (ctx->ExecuteFlag) {
  1476.       (*ctx->Exec.InitNames)( ctx );
  1477.    }
  1478. }
  1479.  
  1480.  
  1481. void gl_save_Lightfv( GLcontext *ctx, GLenum light, GLenum pname,
  1482.                       const GLfloat *params, GLint numparams )
  1483. {
  1484.    Node *n = alloc_instruction( ctx, OPCODE_LIGHT, 6 );
  1485.    if (OPCODE_LIGHT) {
  1486.       GLint i;
  1487.       n[1].e = light;
  1488.       n[2].e = pname;
  1489.       for (i=0;i<numparams;i++) {
  1490.      n[3+i].f = params[i];
  1491.       }
  1492.    }
  1493.    if (ctx->ExecuteFlag) {
  1494.       (*ctx->Exec.Lightfv)( ctx, light, pname, params, numparams );
  1495.    }
  1496. }
  1497.  
  1498.  
  1499. void gl_save_LightModelfv( GLcontext *ctx,
  1500.                            GLenum pname, const GLfloat *params )
  1501. {
  1502.    Node *n = alloc_instruction( ctx, OPCODE_LIGHT_MODEL, 5 );
  1503.    if (n) {
  1504.       n[1].e = pname;
  1505.       n[2].f = params[0];
  1506.       n[3].f = params[1];
  1507.       n[4].f = params[2];
  1508.       n[5].f = params[3];
  1509.    }
  1510.    if (ctx->ExecuteFlag) {
  1511.       (*ctx->Exec.LightModelfv)( ctx, pname, params );
  1512.    }
  1513. }
  1514.  
  1515.  
  1516. void gl_save_LineStipple( GLcontext *ctx, GLint factor, GLushort pattern )
  1517. {
  1518.    Node *n = alloc_instruction( ctx, OPCODE_LINE_STIPPLE, 2 );
  1519.    if (n) {
  1520.       n[1].i = factor;
  1521.       n[2].us = pattern;
  1522.    }
  1523.    if (ctx->ExecuteFlag) {
  1524.       (*ctx->Exec.LineStipple)( ctx, factor, pattern );
  1525.    }
  1526. }
  1527.  
  1528.  
  1529. void gl_save_LineWidth( GLcontext *ctx, GLfloat width )
  1530. {
  1531.    Node *n = alloc_instruction( ctx, OPCODE_LINE_WIDTH, 1 );
  1532.    if (n) {
  1533.       n[1].f = width;
  1534.    }
  1535.    if (ctx->ExecuteFlag) {
  1536.       (*ctx->Exec.LineWidth)( ctx, width );
  1537.    }
  1538. }
  1539.  
  1540.  
  1541. void gl_save_ListBase( GLcontext *ctx, GLuint base )
  1542. {
  1543.    Node *n = alloc_instruction( ctx, OPCODE_LIST_BASE, 1 );
  1544.    if (n) {
  1545.       n[1].ui = base;
  1546.    }
  1547.    if (ctx->ExecuteFlag) {
  1548.       (*ctx->Exec.ListBase)( ctx, base );
  1549.    }
  1550. }
  1551.  
  1552.  
  1553. void gl_save_LoadIdentity( GLcontext *ctx )
  1554. {
  1555.    (void) alloc_instruction( ctx, OPCODE_LOAD_IDENTITY, 0 );
  1556.    if (ctx->ExecuteFlag) {
  1557.       (*ctx->Exec.LoadIdentity)( ctx );
  1558.    }
  1559. }
  1560.  
  1561.  
  1562. void gl_save_LoadMatrixf( GLcontext *ctx, const GLfloat *m )
  1563. {
  1564.    Node *n = alloc_instruction( ctx, OPCODE_LOAD_MATRIX, 16 );
  1565.    if (n) {
  1566.       GLuint i;
  1567.       for (i=0;i<16;i++) {
  1568.      n[1+i].f = m[i];
  1569.       }
  1570.    }
  1571.    if (ctx->ExecuteFlag) {
  1572.       (*ctx->Exec.LoadMatrixf)( ctx, m );
  1573.    }
  1574. }
  1575.  
  1576.  
  1577. void gl_save_LoadName( GLcontext *ctx, GLuint name )
  1578. {
  1579.    Node *n = alloc_instruction( ctx, OPCODE_LOAD_NAME, 1 );
  1580.    if (n) {
  1581.       n[1].ui = name;
  1582.    }
  1583.    if (ctx->ExecuteFlag) {
  1584.       (*ctx->Exec.LoadName)( ctx, name );
  1585.    }
  1586. }
  1587.  
  1588.  
  1589. void gl_save_LogicOp( GLcontext *ctx, GLenum opcode )
  1590. {
  1591.    Node *n = alloc_instruction( ctx, OPCODE_LOGIC_OP, 1 );
  1592.    if (n) {
  1593.       n[1].e = opcode;
  1594.    }
  1595.    if (ctx->ExecuteFlag) {
  1596.       (*ctx->Exec.LogicOp)( ctx, opcode );
  1597.    }
  1598. }
  1599.  
  1600.  
  1601. void gl_save_Map1f( GLcontext *ctx,
  1602.                    GLenum target, GLfloat u1, GLfloat u2, GLint stride,
  1603.            GLint order, const GLfloat *points, GLboolean retain )
  1604. {
  1605.    Node *n = alloc_instruction( ctx, OPCODE_MAP1, 6 );
  1606.    if (n) {
  1607.       n[1].e = target;
  1608.       n[2].f = u1;
  1609.       n[3].f = u2;
  1610.       n[4].i = stride;
  1611.       n[5].i = order;
  1612.       n[6].data = (void *) points;
  1613.    }
  1614.    if (ctx->ExecuteFlag) {
  1615.       (*ctx->Exec.Map1f)( ctx, target, u1, u2, stride, order, points, GL_TRUE );
  1616.    }
  1617.    (void) retain;
  1618. }
  1619.  
  1620.  
  1621. void gl_save_Map2f( GLcontext *ctx, GLenum target,
  1622.                     GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
  1623.                     GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
  1624.                     const GLfloat *points, GLboolean retain )
  1625. {
  1626.    Node *n = alloc_instruction( ctx, OPCODE_MAP2, 10 );
  1627.    if (n) {
  1628.       n[1].e = target;
  1629.       n[2].f = u1;
  1630.       n[3].f = u2;
  1631.       n[4].f = v1;
  1632.       n[5].f = v2;
  1633.       n[6].i = ustride;
  1634.       n[7].i = vstride;
  1635.       n[8].i = uorder;
  1636.       n[9].i = vorder;
  1637.       n[10].data = (void *) points;
  1638.    }
  1639.    if (ctx->ExecuteFlag) {
  1640.       (*ctx->Exec.Map2f)( ctx, target,
  1641.                         u1, u2, ustride, uorder,
  1642.                         v1, v2, vstride, vorder, points, GL_TRUE );
  1643.    }
  1644.    (void) retain;
  1645. }
  1646.  
  1647.  
  1648. void gl_save_MapGrid1f( GLcontext *ctx, GLint un, GLfloat u1, GLfloat u2 )
  1649. {
  1650.    Node *n = alloc_instruction( ctx, OPCODE_MAPGRID1, 3 );
  1651.    if (n) {
  1652.       n[1].i = un;
  1653.       n[2].f = u1;
  1654.       n[3].f = u2;
  1655.    }
  1656.    if (ctx->ExecuteFlag) {
  1657.       (*ctx->Exec.MapGrid1f)( ctx, un, u1, u2 );
  1658.    }
  1659. }
  1660.  
  1661.  
  1662. void gl_save_MapGrid2f( GLcontext *ctx, 
  1663.                         GLint un, GLfloat u1, GLfloat u2,
  1664.                 GLint vn, GLfloat v1, GLfloat v2 )
  1665. {
  1666.    Node *n = alloc_instruction( ctx, OPCODE_MAPGRID2, 6 );
  1667.    if (n) {
  1668.       n[1].i = un;
  1669.       n[2].f = u1;
  1670.       n[3].f = u2;
  1671.       n[4].i = vn;
  1672.       n[5].f = v1;
  1673.       n[6].f = v2;
  1674.    }
  1675.    if (ctx->ExecuteFlag) {
  1676.       (*ctx->Exec.MapGrid2f)( ctx, un, u1, u2, vn, v1, v2 );
  1677.    }
  1678. }
  1679.  
  1680.  
  1681. void gl_save_Materialfv( GLcontext *ctx,
  1682.                          GLenum face, GLenum pname, const GLfloat *params )
  1683. {
  1684.    Node *n = alloc_instruction( ctx, OPCODE_MATERIAL, 6 );
  1685.    if (n) {
  1686.       n[1].e = face;
  1687.       n[2].e = pname;
  1688.       n[3].f = params[0];
  1689.       n[4].f = params[1];
  1690.       n[5].f = params[2];
  1691.       n[6].f = params[3];
  1692.    }
  1693.    if (ctx->ExecuteFlag) {
  1694.       (*ctx->Exec.Materialfv)( ctx, face, pname, params );
  1695.    }
  1696. }
  1697.  
  1698.  
  1699. void gl_save_MatrixMode( GLcontext *ctx, GLenum mode )
  1700. {
  1701.    Node *n = alloc_instruction( ctx, OPCODE_MATRIX_MODE, 1 );
  1702.    if (n) {
  1703.       n[1].e = mode;
  1704.    }
  1705.    if (ctx->ExecuteFlag) {
  1706.       (*ctx->Exec.MatrixMode)( ctx, mode );
  1707.    }
  1708. }
  1709.  
  1710.  
  1711. void gl_save_MultMatrixf( GLcontext *ctx, const GLfloat *m )
  1712. {
  1713.    Node *n = alloc_instruction( ctx, OPCODE_MULT_MATRIX, 16 );
  1714.    if (n) {
  1715.       GLuint i;
  1716.       for (i=0;i<16;i++) {
  1717.      n[1+i].f = m[i];
  1718.       }
  1719.    }
  1720.    if (ctx->ExecuteFlag) {
  1721.       (*ctx->Exec.MultMatrixf)( ctx, m );
  1722.    }
  1723. }
  1724.  
  1725.  
  1726. void gl_save_NewList( GLcontext *ctx, GLuint list, GLenum mode )
  1727. {
  1728.    /* It's an error to call this function while building a display list */
  1729.    gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
  1730.    (void) list;
  1731.    (void) mode;
  1732. }
  1733.  
  1734.  
  1735. void gl_save_Normal3fv( GLcontext *ctx, const GLfloat norm[3] )
  1736. {
  1737.    Node *n = alloc_instruction( ctx, OPCODE_NORMAL, 3 );
  1738.    if (n) {
  1739.       n[1].f = norm[0];
  1740.       n[2].f = norm[1];
  1741.       n[3].f = norm[2];
  1742.    }
  1743.    if (ctx->ExecuteFlag) {
  1744.       (*ctx->Exec.Normal3fv)( ctx, norm );
  1745.    }
  1746. }
  1747.  
  1748.  
  1749. void gl_save_Normal3f( GLcontext *ctx, GLfloat nx, GLfloat ny, GLfloat nz )
  1750. {
  1751.    Node *n = alloc_instruction( ctx, OPCODE_NORMAL, 3 );
  1752.    if (n) {
  1753.       n[1].f = nx;
  1754.       n[2].f = ny;
  1755.       n[3].f = nz;
  1756.    }
  1757.    if (ctx->ExecuteFlag) {
  1758.       (*ctx->Exec.Normal3f)( ctx, nx, ny, nz );
  1759.    }
  1760. }
  1761.  
  1762.  
  1763. void gl_save_Ortho( GLcontext *ctx, GLdouble left, GLdouble right,
  1764.                     GLdouble bottom, GLdouble top,
  1765.                     GLdouble nearval, GLdouble farval )
  1766. {
  1767.    Node *n = alloc_instruction( ctx, OPCODE_ORTHO, 6 );
  1768.    if (n) {
  1769.       n[1].f = left;
  1770.       n[2].f = right;
  1771.       n[3].f = bottom;
  1772.       n[4].f = top;
  1773.       n[5].f = nearval;
  1774.       n[6].f = farval;
  1775.    }
  1776.    if (ctx->ExecuteFlag) {
  1777.       (*ctx->Exec.Ortho)( ctx, left, right, bottom, top, nearval, farval );
  1778.    }
  1779. }
  1780.  
  1781.  
  1782. void gl_save_PixelMapfv( GLcontext *ctx,
  1783.                          GLenum map, GLint mapsize, const GLfloat *values )
  1784. {
  1785.    Node *n = alloc_instruction( ctx, OPCODE_PIXEL_MAP, 3 );
  1786.    if (n) {
  1787.       n[1].e = map;
  1788.       n[2].i = mapsize;
  1789.       n[3].data  = (void *) malloc( mapsize * sizeof(GLfloat) );
  1790.       MEMCPY( n[3].data, (void *) values, mapsize * sizeof(GLfloat) );
  1791.    }
  1792.    if (ctx->ExecuteFlag) {
  1793.       (*ctx->Exec.PixelMapfv)( ctx, map, mapsize, values );
  1794.    }
  1795. }
  1796.  
  1797.  
  1798. void gl_save_PixelTransferf( GLcontext *ctx, GLenum pname, GLfloat param )
  1799. {
  1800.    Node *n = alloc_instruction( ctx, OPCODE_PIXEL_TRANSFER, 2 );
  1801.    if (n) {
  1802.       n[1].e = pname;
  1803.       n[2].f = param;
  1804.    }
  1805.    if (ctx->ExecuteFlag) {
  1806.       (*ctx->Exec.PixelTransferf)( ctx, pname, param );
  1807.    }
  1808. }
  1809.  
  1810.  
  1811. void gl_save_PixelZoom( GLcontext *ctx, GLfloat xfactor, GLfloat yfactor )
  1812. {
  1813.    Node *n = alloc_instruction( ctx, OPCODE_PIXEL_ZOOM, 2 );
  1814.    if (n) {
  1815.       n[1].f = xfactor;
  1816.       n[2].f = yfactor;
  1817.    }
  1818.    if (ctx->ExecuteFlag) {
  1819.       (*ctx->Exec.PixelZoom)( ctx, xfactor, yfactor );
  1820.    }
  1821. }
  1822.  
  1823.  
  1824. void gl_save_PointParameterfvEXT( GLcontext *ctx, GLenum pname,
  1825.                                   const GLfloat *params)
  1826. {
  1827.    Node *n = alloc_instruction( ctx, OPCODE_POINT_PARAMETERS, 4 );
  1828.    if (n) {
  1829.       n[1].e = pname;
  1830.       n[2].f = params[0];
  1831.       n[3].f = params[1];
  1832.       n[4].f = params[2];
  1833.    }
  1834.    if (ctx->ExecuteFlag) {
  1835.       (*ctx->Exec.PointParameterfvEXT)( ctx, pname, params );
  1836.    }
  1837. }
  1838.  
  1839.  
  1840. void gl_save_PointSize( GLcontext *ctx, GLfloat size )
  1841. {
  1842.    Node *n = alloc_instruction( ctx, OPCODE_POINT_SIZE, 1 );
  1843.    if (n) {
  1844.       n[1].f = size;
  1845.    }
  1846.    if (ctx->ExecuteFlag) {
  1847.       (*ctx->Exec.PointSize)( ctx, size );
  1848.    }
  1849. }
  1850.  
  1851.  
  1852. void gl_save_PolygonMode( GLcontext *ctx, GLenum face, GLenum mode )
  1853. {
  1854.    Node *n = alloc_instruction( ctx, OPCODE_POLYGON_MODE, 2 );
  1855.    if (n) {
  1856.       n[1].e = face;
  1857.       n[2].e = mode;
  1858.    }
  1859.    if (ctx->ExecuteFlag) {
  1860.       (*ctx->Exec.PolygonMode)( ctx, face, mode );
  1861.    }
  1862. }
  1863.  
  1864.  
  1865. /*
  1866.  * Polygon stipple must have been upacked already!
  1867.  */
  1868. void gl_save_PolygonStipple( GLcontext *ctx, const GLuint *pattern )
  1869. {
  1870.    Node *n = alloc_instruction( ctx, OPCODE_POLYGON_STIPPLE, 1 );
  1871.    if (n) {
  1872.       void *data;
  1873.       n[1].data = malloc( 32 * 4 );
  1874.       data = n[1].data;   /* This needed for Acorn compiler */
  1875.       MEMCPY( data, pattern, 32 * 4 );
  1876.    }
  1877.    if (ctx->ExecuteFlag) {
  1878.       (*ctx->Exec.PolygonStipple)( ctx, pattern );
  1879.    }
  1880. }
  1881.  
  1882.  
  1883. void gl_save_PolygonOffset( GLcontext *ctx, GLfloat factor, GLfloat units )
  1884. {
  1885.    Node *n = alloc_instruction( ctx, OPCODE_POLYGON_OFFSET, 2 );
  1886.    if (n) {
  1887.       n[1].f = factor;
  1888.       n[2].f = units;
  1889.    }
  1890.    if (ctx->ExecuteFlag) {
  1891.       (*ctx->Exec.PolygonOffset)( ctx, factor, units );
  1892.    }
  1893. }
  1894.  
  1895.  
  1896. void gl_save_PopAttrib( GLcontext *ctx )
  1897. {
  1898.    (void) alloc_instruction( ctx, OPCODE_POP_ATTRIB, 0 );
  1899.    if (ctx->ExecuteFlag) {
  1900.       (*ctx->Exec.PopAttrib)( ctx );
  1901.    }
  1902. }
  1903.  
  1904.  
  1905. void gl_save_PopMatrix( GLcontext *ctx )
  1906. {
  1907.    (void) alloc_instruction( ctx, OPCODE_POP_MATRIX, 0 );
  1908.    if (ctx->ExecuteFlag) {
  1909.       (*ctx->Exec.PopMatrix)( ctx );
  1910.    }
  1911. }
  1912.  
  1913.  
  1914. void gl_save_PopName( GLcontext *ctx )
  1915. {
  1916.    (void) alloc_instruction( ctx, OPCODE_POP_NAME, 0 );
  1917.    if (ctx->ExecuteFlag) {
  1918.       (*ctx->Exec.PopName)( ctx );
  1919.    }
  1920. }
  1921.  
  1922.  
  1923. void gl_save_PrioritizeTextures( GLcontext *ctx,
  1924.                                  GLsizei num, const GLuint *textures,
  1925.                                  const GLclampf *priorities )
  1926. {
  1927.    GLint i;
  1928.  
  1929.    for (i=0;i<num;i++) {
  1930.       Node *n = alloc_instruction( ctx,  OPCODE_PRIORITIZE_TEXTURE, 2 );
  1931.       if (n) {
  1932.          n[1].ui = textures[i];
  1933.          n[2].f = priorities[i];
  1934.       }
  1935.    }
  1936.    if (ctx->ExecuteFlag) {
  1937.       (*ctx->Exec.PrioritizeTextures)( ctx, num, textures, priorities );
  1938.    }
  1939. }
  1940.  
  1941.  
  1942. void gl_save_PushAttrib( GLcontext *ctx, GLbitfield mask )
  1943. {
  1944.    Node *n = alloc_instruction( ctx, OPCODE_PUSH_ATTRIB, 1 );
  1945.    if (n) {
  1946.       n[1].bf = mask;
  1947.    }
  1948.    if (ctx->ExecuteFlag) {
  1949.       (*ctx->Exec.PushAttrib)( ctx, mask );
  1950.    }
  1951. }
  1952.  
  1953.  
  1954. void gl_save_PushMatrix( GLcontext *ctx )
  1955. {
  1956.    (void) alloc_instruction( ctx, OPCODE_PUSH_MATRIX, 0 );
  1957.    if (ctx->ExecuteFlag) {
  1958.       (*ctx->Exec.PushMatrix)( ctx );
  1959.    }
  1960. }
  1961.  
  1962.  
  1963. void gl_save_PushName( GLcontext *ctx, GLuint name )
  1964. {
  1965.    Node *n = alloc_instruction( ctx, OPCODE_PUSH_NAME, 1 );
  1966.    if (n) {
  1967.       n[1].ui = name;
  1968.    }
  1969.    if (ctx->ExecuteFlag) {
  1970.       (*ctx->Exec.PushName)( ctx, name );
  1971.    }
  1972. }
  1973.  
  1974.  
  1975. void gl_save_RasterPos4f( GLcontext *ctx,
  1976.                           GLfloat x, GLfloat y, GLfloat z, GLfloat w )
  1977. {
  1978.    Node *n = alloc_instruction( ctx, OPCODE_RASTER_POS, 4 );
  1979.    if (n) {
  1980.       n[1].f = x;
  1981.       n[2].f = y;
  1982.       n[3].f = z;
  1983.       n[4].f = w;
  1984.    }
  1985.    if (ctx->ExecuteFlag) {
  1986.       (*ctx->Exec.RasterPos4f)( ctx, x, y, z, w );
  1987.    }
  1988. }
  1989.  
  1990.  
  1991. void gl_save_PassThrough( GLcontext *ctx, GLfloat token )
  1992. {
  1993.    Node *n = alloc_instruction( ctx, OPCODE_PASSTHROUGH, 1 );
  1994.    if (n) {
  1995.       n[1].f = token;
  1996.    }
  1997.    if (ctx->ExecuteFlag) {
  1998.       (*ctx->Exec.PassThrough)( ctx, token );
  1999.    }
  2000. }
  2001.  
  2002.  
  2003. void gl_save_ReadBuffer( GLcontext *ctx, GLenum mode )
  2004. {
  2005.    Node *n = alloc_instruction( ctx, OPCODE_READ_BUFFER, 1 );
  2006.    if (n) {
  2007.       n[1].e = mode;
  2008.    }
  2009.    if (ctx->ExecuteFlag) {
  2010.       (*ctx->Exec.ReadBuffer)( ctx, mode );
  2011.    }
  2012. }
  2013.  
  2014.  
  2015. void gl_save_Rectf( GLcontext *ctx,
  2016.                     GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
  2017. {
  2018.    Node *n = alloc_instruction( ctx, OPCODE_RECTF, 4 );
  2019.    if (n) {
  2020.       n[1].f = x1;
  2021.       n[2].f = y1;
  2022.       n[3].f = x2;
  2023.       n[4].f = y2;
  2024.    }
  2025.    if (ctx->ExecuteFlag) {
  2026.       (*ctx->Exec.Rectf)( ctx, x1, y1, x2, y2 );
  2027.    }
  2028. }
  2029.  
  2030.  
  2031. void gl_save_Rotatef( GLcontext *ctx, GLfloat angle,
  2032.                       GLfloat x, GLfloat y, GLfloat z )
  2033. {
  2034.    GLfloat m[16];
  2035.    gl_rotation_matrix( angle, x, y, z, m );
  2036.    gl_save_MultMatrixf( ctx, m );  /* save and maybe execute */
  2037. }
  2038.  
  2039.  
  2040. void gl_save_Scalef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z )
  2041. {
  2042.    Node *n = alloc_instruction( ctx, OPCODE_SCALE, 3 );
  2043.    if (n) {
  2044.       n[1].f = x;
  2045.       n[2].f = y;
  2046.       n[3].f = z;
  2047.    }
  2048.    if (ctx->ExecuteFlag) {
  2049.       (*ctx->Exec.Scalef)( ctx, x, y, z );
  2050.    }
  2051. }
  2052.  
  2053.  
  2054. void gl_save_Scissor( GLcontext *ctx,
  2055.                       GLint x, GLint y, GLsizei width, GLsizei height )
  2056. {
  2057.    Node *n = alloc_instruction( ctx, OPCODE_SCISSOR, 4 );
  2058.    if (n) {
  2059.       n[1].i = x;
  2060.       n[2].i = y;
  2061.       n[3].i = width;
  2062.       n[4].i = height;
  2063.    }
  2064.    if (ctx->ExecuteFlag) {
  2065.       (*ctx->Exec.Scissor)( ctx, x, y, width, height );
  2066.    }
  2067. }
  2068.  
  2069.  
  2070. void gl_save_ShadeModel( GLcontext *ctx, GLenum mode )
  2071. {
  2072.    Node *n = alloc_instruction( ctx, OPCODE_SHADE_MODEL, 1 );
  2073.    if (n) {
  2074.       n[1].e = mode;
  2075.    }
  2076.    if (ctx->ExecuteFlag) {
  2077.       (*ctx->Exec.ShadeModel)( ctx, mode );
  2078.    }
  2079. }
  2080.  
  2081.  
  2082. void gl_save_StencilFunc( GLcontext *ctx, GLenum func, GLint ref, GLuint mask )
  2083. {
  2084.    Node *n = alloc_instruction( ctx, OPCODE_STENCIL_FUNC, 3 );
  2085.    if (n) {
  2086.       n[1].e = func;
  2087.       n[2].i = ref;
  2088.       n[3].ui = mask;
  2089.    }
  2090.    if (ctx->ExecuteFlag) {
  2091.       (*ctx->Exec.StencilFunc)( ctx, func, ref, mask );
  2092.    }
  2093. }
  2094.  
  2095.  
  2096. void gl_save_StencilMask( GLcontext *ctx, GLuint mask )
  2097. {
  2098.    Node *n = alloc_instruction( ctx, OPCODE_STENCIL_MASK, 1 );
  2099.    if (n) {
  2100.       n[1].ui = mask;
  2101.    }
  2102.    if (ctx->ExecuteFlag) {
  2103.       (*ctx->Exec.StencilMask)( ctx, mask );
  2104.    }
  2105. }
  2106.  
  2107.  
  2108. void gl_save_StencilOp( GLcontext *ctx,
  2109.                         GLenum fail, GLenum zfail, GLenum zpass )
  2110. {
  2111.    Node *n = alloc_instruction( ctx, OPCODE_STENCIL_OP, 3 );
  2112.    if (n) {
  2113.       n[1].e = fail;
  2114.       n[2].e = zfail;
  2115.       n[3].e = zpass;
  2116.    }
  2117.    if (ctx->ExecuteFlag) {
  2118.       (*ctx->Exec.StencilOp)( ctx, fail, zfail, zpass );
  2119.    }
  2120. }
  2121.  
  2122.  
  2123. void gl_save_TexCoord2f( GLcontext *ctx, GLfloat s, GLfloat t )
  2124. {
  2125.    Node *n = alloc_instruction( ctx, OPCODE_TEXCOORD2, 2 );
  2126.    if (n) {
  2127.       n[1].f = s;
  2128.       n[2].f = t;
  2129.    }
  2130.    if (ctx->ExecuteFlag) {
  2131.       (*ctx->Exec.TexCoord2f)( ctx, s, t );
  2132.    }
  2133. }
  2134.  
  2135.  
  2136. void gl_save_TexCoord4f( GLcontext *ctx, GLfloat s, GLfloat t,
  2137.                                          GLfloat r, GLfloat q )
  2138. {
  2139.    Node *n = alloc_instruction( ctx, OPCODE_TEXCOORD4, 4 );
  2140.    if (n) {
  2141.       n[1].f = s;
  2142.       n[2].f = t;
  2143.       n[3].f = r;
  2144.       n[4].f = q;
  2145.    }
  2146.    if (ctx->ExecuteFlag) {
  2147.       (*ctx->Exec.TexCoord4f)( ctx, s, t, r, q );
  2148.    }
  2149. }
  2150.  
  2151.  
  2152. void gl_save_TexEnvfv( GLcontext *ctx,
  2153.                        GLenum target, GLenum pname, const GLfloat *params )
  2154. {
  2155.    Node *n = alloc_instruction( ctx, OPCODE_TEXENV, 6 );
  2156.    if (n) {
  2157.       n[1].e = target;
  2158.       n[2].e = pname;
  2159.       n[3].f = params[0];
  2160.       n[4].f = params[1];
  2161.       n[5].f = params[2];
  2162.       n[6].f = params[3];
  2163.    }
  2164.    if (ctx->ExecuteFlag) {
  2165.       (*ctx->Exec.TexEnvfv)( ctx, target, pname, params );
  2166.    }
  2167. }
  2168.  
  2169.  
  2170. void gl_save_TexGenfv( GLcontext *ctx,
  2171.                        GLenum coord, GLenum pname, const GLfloat *params )
  2172. {
  2173.    Node *n = alloc_instruction( ctx, OPCODE_TEXGEN, 6 );
  2174.    if (n) {
  2175.       n[1].e = coord;
  2176.       n[2].e = pname;
  2177.       n[3].f = params[0];
  2178.       n[4].f = params[1];
  2179.       n[5].f = params[2];
  2180.       n[6].f = params[3];
  2181.    }
  2182.    if (ctx->ExecuteFlag) {
  2183.       (*ctx->Exec.TexGenfv)( ctx, coord, pname, params );
  2184.    }
  2185. }
  2186.  
  2187.  
  2188. void gl_save_TexParameterfv( GLcontext *ctx, GLenum target,
  2189.                              GLenum pname, const GLfloat *params )
  2190. {
  2191.    Node *n = alloc_instruction( ctx, OPCODE_TEXPARAMETER, 6 );
  2192.    if (n) {
  2193.       n[1].e = target;
  2194.       n[2].e = pname;
  2195.       n[3].f = params[0];
  2196.       n[4].f = params[1];
  2197.       n[5].f = params[2];
  2198.       n[6].f = params[3];
  2199.    }
  2200.    if (ctx->ExecuteFlag) {
  2201.       (*ctx->Exec.TexParameterfv)( ctx, target, pname, params );
  2202.    }
  2203. }
  2204.  
  2205.  
  2206. void gl_save_TexImage1D( GLcontext *ctx, GLenum target,
  2207.                          GLint level, GLint components,
  2208.              GLsizei width, GLint border,
  2209.                          GLenum format, GLenum type,
  2210.              struct gl_image *teximage )
  2211. {
  2212.    Node *n = alloc_instruction( ctx, OPCODE_TEX_IMAGE1D, 8 );
  2213.    if (n) {
  2214.       n[1].e = target;
  2215.       n[2].i = level;
  2216.       n[3].i = components;
  2217.       n[4].i = (GLint) width;
  2218.       n[5].i = border;
  2219.       n[6].e = format;
  2220.       n[7].e = type;
  2221.       n[8].data = teximage;
  2222.       if (teximage) {
  2223.          /* this prevents gl_TexImage2D() from freeing the image */
  2224.          teximage->RefCount = 1;
  2225.       }
  2226.    }
  2227.    if (ctx->ExecuteFlag) {
  2228.       (*ctx->Exec.TexImage1D)( ctx, target, level, components, width,
  2229.                         border, format, type, teximage );
  2230.    }
  2231. }
  2232.  
  2233.  
  2234. void gl_save_TexImage2D( GLcontext *ctx, GLenum target,
  2235.                          GLint level, GLint components,
  2236.              GLsizei width, GLsizei height, GLint border,
  2237.                          GLenum format, GLenum type,
  2238.              struct gl_image *teximage )
  2239. {
  2240.    Node *n = alloc_instruction( ctx, OPCODE_TEX_IMAGE2D, 9 );
  2241.    if (n) {
  2242.       n[1].e = target;
  2243.       n[2].i = level;
  2244.       n[3].i = components;
  2245.       n[4].i = (GLint) width;
  2246.       n[5].i = (GLint) height;
  2247.       n[6].i = border;
  2248.       n[7].e = format;
  2249.       n[8].e = type;
  2250.       n[9].data = teximage;
  2251.       if (teximage) {
  2252.          /* this prevents gl_TexImage2D() from freeing the image */
  2253.          teximage->RefCount = 1;
  2254.       }
  2255.    }
  2256.    if (ctx->ExecuteFlag) {
  2257.       (*ctx->Exec.TexImage2D)( ctx, target, level, components, width,
  2258.                         height, border, format, type, teximage );
  2259.    }
  2260. }
  2261.  
  2262.  
  2263. void gl_save_TexImage3DEXT( GLcontext *ctx, GLenum target,
  2264.                             GLint level, GLint components,
  2265.                             GLsizei width, GLsizei height, GLsizei depth,
  2266.                             GLint border,
  2267.                             GLenum format, GLenum type,
  2268.                             struct gl_image *teximage )
  2269. {
  2270.    Node *n = alloc_instruction( ctx, OPCODE_TEX_IMAGE3D, 10 );
  2271.    if (n) {
  2272.       n[1].e = target;
  2273.       n[2].i = level;
  2274.       n[3].i = components;
  2275.       n[4].i = (GLint) width;
  2276.       n[5].i = (GLint) height;
  2277.       n[6].i = (GLint) depth; 
  2278.       n[7].i = border;
  2279.       n[8].e = format;
  2280.       n[9].e = type;
  2281.       n[10].data = teximage;
  2282.    }
  2283.    if (ctx->ExecuteFlag) {
  2284.       (*ctx->Exec.TexImage3DEXT)( ctx, target, level, components, width,
  2285.                            height, depth, border, format, type, teximage );
  2286.    }
  2287. }
  2288.  
  2289.  
  2290. void gl_save_TexSubImage1D( GLcontext *ctx,
  2291.                             GLenum target, GLint level, GLint xoffset,
  2292.                             GLsizei width, GLenum format, GLenum type,
  2293.                             struct gl_image *image )
  2294. {
  2295.    Node *n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE1D, 7 );
  2296.    if (n) {
  2297.       n[1].e = target;
  2298.       n[2].i = level;
  2299.       n[3].i = xoffset;
  2300.       n[4].i = (GLint) width;
  2301.       n[5].e = format;
  2302.       n[6].e = type;
  2303.       n[7].data = image;
  2304.       if (image)
  2305.          image->RefCount = 1;
  2306.    }
  2307.    if (ctx->ExecuteFlag) {
  2308.       (*ctx->Exec.TexSubImage1D)( ctx, target, level, xoffset, width,
  2309.                            format, type, image );
  2310.    }
  2311. }
  2312.  
  2313.  
  2314. void gl_save_TexSubImage2D( GLcontext *ctx,
  2315.                             GLenum target, GLint level,
  2316.                             GLint xoffset, GLint yoffset,
  2317.                             GLsizei width, GLsizei height,
  2318.                             GLenum format, GLenum type,
  2319.                             struct gl_image *image )
  2320. {
  2321.    Node *n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE2D, 9 );
  2322.    if (n) {
  2323.       n[1].e = target;
  2324.       n[2].i = level;
  2325.       n[3].i = xoffset;
  2326.       n[4].i = yoffset;
  2327.       n[5].i = (GLint) width;
  2328.       n[6].i = (GLint) height;
  2329.       n[7].e = format;
  2330.       n[8].e = type;
  2331.       n[9].data = image;
  2332.       if (image)
  2333.          image->RefCount = 1;
  2334.    }
  2335.    if (ctx->ExecuteFlag) {
  2336.       (*ctx->Exec.TexSubImage2D)( ctx, target, level, xoffset, yoffset,
  2337.                            width, height, format, type, image );
  2338.    }
  2339. }
  2340.  
  2341.  
  2342. void gl_save_TexSubImage3DEXT( GLcontext *ctx,
  2343.                                GLenum target, GLint level,
  2344.                                GLint xoffset, GLint yoffset,GLint zoffset,
  2345.                                GLsizei width, GLsizei height, GLsizei depth,
  2346.                                GLenum format, GLenum type,
  2347.                                struct gl_image *image )
  2348. {
  2349.    Node *n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE3D, 11 );
  2350.    if (n) {
  2351.       n[1].e = target;
  2352.       n[2].i = level;
  2353.       n[3].i = xoffset;
  2354.       n[4].i = yoffset;
  2355.       n[5].i = zoffset;
  2356.       n[6].i = (GLint) width;
  2357.       n[7].i = (GLint) height;
  2358.       n[8].i = (GLint) depth;
  2359.       n[9].e = format;
  2360.       n[10].e = type;
  2361.       n[11].data = image;
  2362.       if (image)
  2363.          image->RefCount = 1;
  2364.    }
  2365.    if (ctx->ExecuteFlag) {
  2366.       (*ctx->Exec.TexSubImage3DEXT)( ctx, target, level, xoffset, yoffset, zoffset,
  2367.                               width, height, depth, format, type, image );
  2368.    }
  2369. }
  2370.  
  2371.  
  2372. void gl_save_Translatef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z )
  2373. {
  2374.    Node *n = alloc_instruction( ctx,  OPCODE_TRANSLATE, 3 );
  2375.    if (n) {
  2376.       n[1].f = x;
  2377.       n[2].f = y;
  2378.       n[3].f = z;
  2379.    }
  2380.    if (ctx->ExecuteFlag) {
  2381.       (*ctx->Exec.Translatef)( ctx, x, y, z );
  2382.    }
  2383. }
  2384.  
  2385.  
  2386. void gl_save_Vertex2f( GLcontext *ctx, GLfloat x, GLfloat y )
  2387. {
  2388.    Node *n = alloc_instruction( ctx,  OPCODE_VERTEX2, 2 );
  2389.    if (n) {
  2390.       n[1].f = x;
  2391.       n[2].f = y;
  2392.    }
  2393.    if (ctx->ExecuteFlag) {
  2394.       (*ctx->Exec.Vertex2f)( ctx, x, y );
  2395.    }
  2396. }
  2397.  
  2398.  
  2399. void gl_save_Vertex3f( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z )
  2400. {
  2401.    Node *n = alloc_instruction( ctx,  OPCODE_VERTEX3, 3 );
  2402.    if (n) {
  2403.       n[1].f = x;
  2404.       n[2].f = y;
  2405.       n[3].f = z;
  2406.    }
  2407.    if (ctx->ExecuteFlag) {
  2408.       (*ctx->Exec.Vertex3f)( ctx, x, y, z );
  2409.    }
  2410. }
  2411.  
  2412.  
  2413. void gl_save_Vertex4f( GLcontext *ctx,
  2414.                        GLfloat x, GLfloat y, GLfloat z, GLfloat w )
  2415. {
  2416.    Node *n = alloc_instruction( ctx,  OPCODE_VERTEX4, 4 );
  2417.    if (n) {
  2418.       n[1].f = x;
  2419.       n[2].f = y;
  2420.       n[3].f = z;
  2421.       n[4].f = w;
  2422.    }
  2423.    if (ctx->ExecuteFlag) {
  2424.       (*ctx->Exec.Vertex4f)( ctx, x, y, z, w );
  2425.    }
  2426. }
  2427.  
  2428.  
  2429. void gl_save_Vertex3fv( GLcontext *ctx, const GLfloat v[3] )
  2430. {
  2431.    Node *n = alloc_instruction( ctx,  OPCODE_VERTEX3, 3 );
  2432.    if (n) {
  2433.       n[1].f = v[0];
  2434.       n[2].f = v[1];
  2435.       n[3].f = v[2];
  2436.    }
  2437.    if (ctx->ExecuteFlag) {
  2438.       (*ctx->Exec.Vertex3fv)( ctx, v );
  2439.    }
  2440. }
  2441.  
  2442.  
  2443. void gl_save_Viewport( GLcontext *ctx,
  2444.                        GLint x, GLint y, GLsizei width, GLsizei height )
  2445. {
  2446.    Node *n = alloc_instruction( ctx,  OPCODE_VIEWPORT, 4 );
  2447.    if (n) {
  2448.       n[1].i = x;
  2449.       n[2].i = y;
  2450.       n[3].i = (GLint) width;
  2451.       n[4].i = (GLint) height;
  2452.    }
  2453.    if (ctx->ExecuteFlag) {
  2454.       (*ctx->Exec.Viewport)( ctx, x, y, width, height );
  2455.    }
  2456. }
  2457.  
  2458.  
  2459. void gl_save_WindowPos4fMESA( GLcontext *ctx,
  2460.                               GLfloat x, GLfloat y, GLfloat z, GLfloat w )
  2461. {
  2462.    Node *n = alloc_instruction( ctx,  OPCODE_WINDOW_POS, 4 );
  2463.    if (n) {
  2464.       n[1].f = x;
  2465.       n[2].f = y;
  2466.       n[3].f = z;
  2467.       n[4].f = w;
  2468.    }
  2469.    if (ctx->ExecuteFlag) {
  2470.       (*ctx->Exec.WindowPos4fMESA)( ctx, x, y, z, w );
  2471.    }
  2472. }
  2473.  
  2474.  
  2475. /* GL_SGIS_multitexture */
  2476. void gl_save_MultiTexCoord4f( GLcontext *ctx, GLenum target,
  2477.                               GLfloat s, GLfloat t, GLfloat r, GLfloat q )
  2478. {
  2479.    Node *n = alloc_instruction( ctx, OPCODE_MULTI_TEXCOORD4, 5);
  2480.    if (n) {
  2481.       n[1].e = target;
  2482.       n[2].f = s;
  2483.       n[3].f = t;
  2484.       n[4].f = r;
  2485.       n[5].f = q;
  2486.    }
  2487.    if (ctx->ExecuteFlag) {
  2488.       (*ctx->Exec.MultiTexCoord4f)( ctx, target, s, t, r, q );
  2489.    }
  2490. }
  2491.  
  2492.  
  2493. /* GL_SGIS_multitexture */
  2494. void gl_save_SelectTextureSGIS( GLcontext *ctx, GLenum target )
  2495. {
  2496.    Node *n = alloc_instruction( ctx, OPCODE_SELECT_TEXTURE_SGIS, 1 );
  2497.    if (n) {
  2498.       n[1].e = target;
  2499.    }
  2500.    if (ctx->ExecuteFlag) {
  2501.       (*ctx->Exec.SelectTextureSGIS)( ctx, target );
  2502.    }
  2503. }
  2504.  
  2505.  
  2506. /* GL_EXT_multitexture */
  2507. void gl_save_SelectTexture( GLcontext *ctx, GLenum target )
  2508. {
  2509.    Node *n = alloc_instruction( ctx, OPCODE_SELECT_TEXTURE, 1 );
  2510.    if (n) {
  2511.       n[1].e = target;
  2512.    }
  2513.    if (ctx->ExecuteFlag) {
  2514.       (*ctx->Exec.SelectTexture)( ctx, target );
  2515.    }
  2516. }
  2517.  
  2518.  
  2519. /* GL_SGIS_multitexture */
  2520. void gl_save_SelectTextureCoordSet( GLcontext *ctx, GLenum target )
  2521. {
  2522.    Node *n = alloc_instruction( ctx, OPCODE_SELECT_TEXTURE_COORD_SET, 1 );
  2523.    if (n) {
  2524.       n[1].e = target;
  2525.    }
  2526.    if (ctx->ExecuteFlag) {
  2527.       (*ctx->Exec.SelectTextureCoordSet)( ctx, target );
  2528.    }
  2529. }
  2530.  
  2531.  
  2532. /* GL_EXT_multitexture */
  2533. void gl_save_SelectTextureTransform( GLcontext *ctx, GLenum target )
  2534. {
  2535.    Node *n = alloc_instruction( ctx, OPCODE_SELECT_TEXTURE_TRANSFORM, 1 );
  2536.    if (n) {
  2537.       n[1].e = target;
  2538.    }
  2539.    if (ctx->ExecuteFlag) {
  2540.       (*ctx->Exec.SelectTextureTransform)( ctx, target );
  2541.    }
  2542. }
  2543.  
  2544.  
  2545.  
  2546.  
  2547.  
  2548.  
  2549. /**********************************************************************/
  2550. /*                     Display list execution                         */
  2551. /**********************************************************************/
  2552.  
  2553.  
  2554. /*
  2555.  * Execute a display list.  Note that the ListBase offset must have already
  2556.  * been added before calling this function.  I.e. the list argument is
  2557.  * the absolute list number, not relative to ListBase.
  2558.  * Input:  list - display list number
  2559.  */
  2560. static void execute_list( GLcontext *ctx, GLuint list )
  2561. {
  2562.    Node *n;
  2563.    GLboolean done;
  2564.    OpCode opcode;
  2565.  
  2566.    if (!gl_IsList(ctx,list))
  2567.       return;
  2568.  
  2569.    ctx->CallDepth++;
  2570.  
  2571.    n = (Node *) HashLookup(ctx->Shared->DisplayList, list);
  2572.  
  2573.    done = GL_FALSE;
  2574.    while (!done) {
  2575.       opcode = n[0].opcode;
  2576.  
  2577.       switch (opcode) {
  2578.      /* Frequently called functions: */
  2579.          case OPCODE_VERTEX2:
  2580.             (*ctx->Exec.Vertex2f)( ctx, n[1].f, n[2].f );
  2581.             break;
  2582.          case OPCODE_VERTEX3:
  2583.             (*ctx->Exec.Vertex3f)( ctx, n[1].f, n[2].f, n[3].f );
  2584.             break;
  2585.          case OPCODE_VERTEX4:
  2586.             (*ctx->Exec.Vertex4f)( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
  2587.             break;
  2588.          case OPCODE_NORMAL:
  2589.             ctx->Current.Normal[0] = n[1].f;
  2590.             ctx->Current.Normal[1] = n[2].f;
  2591.             ctx->Current.Normal[2] = n[3].f;
  2592.             ctx->VB->MonoNormal = GL_FALSE;
  2593.             break;
  2594.      case OPCODE_COLOR_4UB:
  2595.             (*ctx->Exec.Color4ub)( ctx, n[1].ub, n[2].ub, n[3].ub, n[4].ub );
  2596.         break;
  2597.      case OPCODE_COLOR_3F:
  2598.             (*ctx->Exec.Color3f)( ctx, n[1].f, n[2].f, n[3].f );
  2599.             break;
  2600.      case OPCODE_COLOR_4F:
  2601.             (*ctx->Exec.Color4f)( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
  2602.             break;
  2603.          case OPCODE_INDEX:
  2604.             ctx->Current.Index = n[1].ui;
  2605.             ctx->VB->MonoColor = GL_FALSE;
  2606.             break;
  2607.          case OPCODE_BEGIN:
  2608.             gl_Begin( ctx, n[1].e );
  2609.             break;
  2610.          case OPCODE_END:
  2611.             gl_End( ctx );
  2612.             break;
  2613.      case OPCODE_TEXCOORD2:
  2614.         ctx->Current.TexCoord[0] = n[1].f;
  2615.         ctx->Current.TexCoord[1] = n[2].f;
  2616.             if (ctx->VB->TexCoordSize==4) {
  2617.                ctx->Current.TexCoord[2] = 0.0F;
  2618.                ctx->Current.TexCoord[3] = 1.0F;
  2619.             }
  2620.         break;
  2621.      case OPCODE_TEXCOORD4:
  2622.         ctx->Current.TexCoord[0] = n[1].f;
  2623.         ctx->Current.TexCoord[1] = n[2].f;
  2624.         ctx->Current.TexCoord[2] = n[3].f;
  2625.         ctx->Current.TexCoord[3] = n[4].f;
  2626.             if (ctx->VB->TexCoordSize==2) {
  2627.                /* Switch to 4-component texcoords */
  2628.                ctx->VB->TexCoordSize = 4;
  2629.                gl_set_vertex_function(ctx);
  2630.             }
  2631.         break;
  2632.  
  2633.      /* Everything Else: */
  2634.          case OPCODE_ACCUM:
  2635.         gl_Accum( ctx, n[1].e, n[2].f );
  2636.         break;
  2637.          case OPCODE_ALPHA_FUNC:
  2638.         gl_AlphaFunc( ctx, n[1].e, n[2].f );
  2639.         break;
  2640.          case OPCODE_BIND_TEXTURE:
  2641.             gl_BindTexture( ctx, n[1].e, n[2].ui );
  2642.             break;
  2643.      case OPCODE_BITMAP:
  2644.         gl_Bitmap( ctx, (GLsizei) n[1].i, (GLsizei) n[2].i,
  2645.                n[3].f, n[4].f,
  2646.                n[5].f, n[6].f,
  2647.                (struct gl_image *) n[7].data );
  2648.         break;
  2649.      case OPCODE_BLEND_COLOR:
  2650.         gl_BlendColor( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
  2651.         break;
  2652.      case OPCODE_BLEND_EQUATION:
  2653.         gl_BlendEquation( ctx, n[1].e );
  2654.         break;
  2655.      case OPCODE_BLEND_FUNC:
  2656.         gl_BlendFunc( ctx, n[1].e, n[2].e );
  2657.         break;
  2658.          case OPCODE_CALL_LIST:
  2659.         /* Generated by glCallList(), don't add ListBase */
  2660.             if (ctx->CallDepth<MAX_LIST_NESTING) {
  2661.                execute_list( ctx, n[1].ui );
  2662.             }
  2663.             break;
  2664.          case OPCODE_CALL_LIST_OFFSET:
  2665.         /* Generated by glCallLists() so we must add ListBase */
  2666.             if (ctx->CallDepth<MAX_LIST_NESTING) {
  2667.                execute_list( ctx, ctx->List.ListBase + n[1].ui );
  2668.             }
  2669.             break;
  2670.      case OPCODE_CLEAR:
  2671.         gl_Clear( ctx, n[1].bf );
  2672.         break;
  2673.      case OPCODE_CLEAR_COLOR:
  2674.         gl_ClearColor( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
  2675.         break;
  2676.      case OPCODE_CLEAR_ACCUM:
  2677.         gl_ClearAccum( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
  2678.         break;
  2679.      case OPCODE_CLEAR_DEPTH:
  2680.         gl_ClearDepth( ctx, (GLclampd) n[1].f );
  2681.         break;
  2682.      case OPCODE_CLEAR_INDEX:
  2683.         gl_ClearIndex( ctx, n[1].ui );
  2684.         break;
  2685.      case OPCODE_CLEAR_STENCIL:
  2686.         gl_ClearStencil( ctx, n[1].i );
  2687.         break;
  2688.          case OPCODE_CLIP_PLANE:
  2689.             {
  2690.                GLfloat equ[4];
  2691.                equ[0] = n[2].f;
  2692.                equ[1] = n[3].f;
  2693.                equ[2] = n[4].f;
  2694.                equ[3] = n[5].f;
  2695.                gl_ClipPlane( ctx, n[1].e, equ );
  2696.             }
  2697.             break;
  2698.      case OPCODE_COLOR_MASK:
  2699.         gl_ColorMask( ctx, n[1].b, n[2].b, n[3].b, n[4].b );
  2700.         break;
  2701.      case OPCODE_COLOR_MATERIAL:
  2702.         gl_ColorMaterial( ctx, n[1].e, n[2].e );
  2703.         break;
  2704.          case OPCODE_COLOR_TABLE:
  2705.             gl_ColorTable( ctx, n[1].e, n[2].e, (struct gl_image *) n[3].data);
  2706.             break;
  2707.          case OPCODE_COLOR_SUB_TABLE:
  2708.             gl_ColorSubTable( ctx, n[1].e, n[2].i,
  2709.                               (struct gl_image *) n[3].data);
  2710.             break;
  2711.      case OPCODE_COPY_PIXELS:
  2712.         gl_CopyPixels( ctx, n[1].i, n[2].i,
  2713.                (GLsizei) n[3].i, (GLsizei) n[4].i, n[5].e );
  2714.         break;
  2715.          case OPCODE_COPY_TEX_IMAGE1D:
  2716.         gl_CopyTexImage1D( ctx, n[1].e, n[2].i, n[3].e, n[4].i,
  2717.                                n[5].i, n[6].i, n[7].i );
  2718.             break;
  2719.          case OPCODE_COPY_TEX_IMAGE2D:
  2720.         gl_CopyTexImage2D( ctx, n[1].e, n[2].i, n[3].e, n[4].i,
  2721.                                n[5].i, n[6].i, n[7].i, n[8].i );
  2722.             break;
  2723.          case OPCODE_COPY_TEX_SUB_IMAGE1D:
  2724.         gl_CopyTexSubImage1D( ctx, n[1].e, n[2].i, n[3].i, n[4].i,
  2725.                                   n[5].i, n[6].i );
  2726.             break;
  2727.          case OPCODE_COPY_TEX_SUB_IMAGE2D:
  2728.         gl_CopyTexSubImage2D( ctx, n[1].e, n[2].i, n[3].i, n[4].i,
  2729.                                   n[5].i, n[6].i, n[7].i, n[8].i );
  2730.             break;
  2731.          case OPCODE_COPY_TEX_SUB_IMAGE3D:
  2732.             gl_CopyTexSubImage3DEXT( ctx, n[1].e, n[2].i, n[3].i, n[4].i,
  2733.                                      n[5].i, n[6].i, n[7].i, n[8].i , n[9].i);
  2734.             break;
  2735.      case OPCODE_CULL_FACE:
  2736.         gl_CullFace( ctx, n[1].e );
  2737.         break;
  2738.      case OPCODE_DEPTH_FUNC:
  2739.         gl_DepthFunc( ctx, n[1].e );
  2740.         break;
  2741.      case OPCODE_DEPTH_MASK:
  2742.         gl_DepthMask( ctx, n[1].b );
  2743.         break;
  2744.      case OPCODE_DEPTH_RANGE:
  2745.         gl_DepthRange( ctx, (GLclampd) n[1].f, (GLclampd) n[2].f );
  2746.         break;
  2747.      case OPCODE_DISABLE:
  2748.         gl_Disable( ctx, n[1].e );
  2749.         break;
  2750.      case OPCODE_DRAW_BUFFER:
  2751.         gl_DrawBuffer( ctx, n[1].e );
  2752.         break;
  2753.      case OPCODE_DRAW_PIXELS:
  2754.         gl_DrawPixels( ctx, (struct gl_image *) n[1].data );
  2755.         break;
  2756.      case OPCODE_EDGE_FLAG:
  2757.             ctx->Current.EdgeFlag = n[1].b;
  2758.             break;
  2759.      case OPCODE_ENABLE:
  2760.         gl_Enable( ctx, n[1].e );
  2761.         break;
  2762.      case OPCODE_EVALCOORD1:
  2763.         gl_EvalCoord1f( ctx, n[1].f );
  2764.         break;
  2765.      case OPCODE_EVALCOORD2:
  2766.         gl_EvalCoord2f( ctx, n[1].f, n[2].f );
  2767.         break;
  2768.      case OPCODE_EVALMESH1:
  2769.         gl_EvalMesh1( ctx, n[1].e, n[2].i, n[3].i );
  2770.         break;
  2771.      case OPCODE_EVALMESH2:
  2772.         gl_EvalMesh2( ctx, n[1].e, n[2].i, n[3].i, n[4].i, n[5].i );
  2773.         break;
  2774.      case OPCODE_EVALPOINT1:
  2775.         gl_EvalPoint1( ctx, n[1].i );
  2776.         break;
  2777.      case OPCODE_EVALPOINT2:
  2778.         gl_EvalPoint2( ctx, n[1].i, n[2].i );
  2779.         break;
  2780.      case OPCODE_FOG:
  2781.         {
  2782.            GLfloat p[4];
  2783.            p[0] = n[2].f;
  2784.            p[1] = n[3].f;
  2785.            p[2] = n[4].f;
  2786.            p[3] = n[5].f;
  2787.            gl_Fogfv( ctx, n[1].e, p );
  2788.         }
  2789.         break;
  2790.      case OPCODE_FRONT_FACE:
  2791.         gl_FrontFace( ctx, n[1].e );
  2792.         break;
  2793.          case OPCODE_FRUSTUM:
  2794.             gl_Frustum( ctx, n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
  2795.             break;
  2796.      case OPCODE_HINT:
  2797.         gl_Hint( ctx, n[1].e, n[2].e );
  2798.         break;
  2799.      case OPCODE_INDEX_MASK:
  2800.         gl_IndexMask( ctx, n[1].ui );
  2801.         break;
  2802.      case OPCODE_INIT_NAMES:
  2803.         gl_InitNames( ctx );
  2804.         break;
  2805.          case OPCODE_LIGHT:
  2806.         {
  2807.            GLfloat p[4];
  2808.            p[0] = n[3].f;
  2809.            p[1] = n[4].f;
  2810.            p[2] = n[5].f;
  2811.            p[3] = n[6].f;
  2812.            gl_Lightfv( ctx, n[1].e, n[2].e, p, 4 );
  2813.         }
  2814.         break;
  2815.          case OPCODE_LIGHT_MODEL:
  2816.         {
  2817.            GLfloat p[4];
  2818.            p[0] = n[2].f;
  2819.            p[1] = n[3].f;
  2820.            p[2] = n[4].f;
  2821.            p[3] = n[5].f;
  2822.            gl_LightModelfv( ctx, n[1].e, p );
  2823.         }
  2824.         break;
  2825.      case OPCODE_LINE_STIPPLE:
  2826.         gl_LineStipple( ctx, n[1].i, n[2].us );
  2827.         break;
  2828.      case OPCODE_LINE_WIDTH:
  2829.         gl_LineWidth( ctx, n[1].f );
  2830.         break;
  2831.      case OPCODE_LIST_BASE:
  2832.         gl_ListBase( ctx, n[1].ui );
  2833.         break;
  2834.      case OPCODE_LOAD_IDENTITY:
  2835.             gl_LoadIdentity( ctx );
  2836.             break;
  2837.      case OPCODE_LOAD_MATRIX:
  2838.         if (sizeof(Node)==sizeof(GLfloat)) {
  2839.            gl_LoadMatrixf( ctx, &n[1].f );
  2840.         }
  2841.         else {
  2842.            GLfloat m[16];
  2843.            GLuint i;
  2844.            for (i=0;i<16;i++) {
  2845.           m[i] = n[1+i].f;
  2846.            }
  2847.            gl_LoadMatrixf( ctx, m );
  2848.         }
  2849.         break;
  2850.      case OPCODE_LOAD_NAME:
  2851.         gl_LoadName( ctx, n[1].ui );
  2852.         break;
  2853.      case OPCODE_LOGIC_OP:
  2854.         gl_LogicOp( ctx, n[1].e );
  2855.         break;
  2856.      case OPCODE_MAP1:
  2857.         gl_Map1f( ctx, n[1].e, n[2].f, n[3].f,
  2858.                       n[4].i, n[5].i, (GLfloat *) n[6].data, GL_TRUE );
  2859.         break;
  2860.      case OPCODE_MAP2:
  2861.         gl_Map2f( ctx, n[1].e,
  2862.                       n[2].f, n[3].f,  /* u1, u2 */
  2863.               n[6].i, n[8].i,  /* ustride, uorder */
  2864.               n[4].f, n[5].f,  /* v1, v2 */
  2865.               n[7].i, n[9].i,  /* vstride, vorder */
  2866.               (GLfloat *) n[10].data,
  2867.                       GL_TRUE);
  2868.         break;
  2869.      case OPCODE_MAPGRID1:
  2870.         gl_MapGrid1f( ctx, n[1].i, n[2].f, n[3].f );
  2871.         break;
  2872.      case OPCODE_MAPGRID2:
  2873.         gl_MapGrid2f( ctx, n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f);
  2874.         break;
  2875.      case OPCODE_MATERIAL:
  2876.         {
  2877.            GLfloat params[4];
  2878.            params[0] = n[3].f;
  2879.            params[1] = n[4].f;
  2880.            params[2] = n[5].f;
  2881.            params[3] = n[6].f;
  2882.            gl_Materialfv( ctx, n[1].e, n[2].e, params );
  2883.         }
  2884.         break;
  2885.          case OPCODE_MATRIX_MODE:
  2886.             gl_MatrixMode( ctx, n[1].e );
  2887.             break;
  2888.      case OPCODE_MULT_MATRIX:
  2889.         if (sizeof(Node)==sizeof(GLfloat)) {
  2890.            gl_MultMatrixf( ctx, &n[1].f );
  2891.         }
  2892.         else {
  2893.            GLfloat m[16];
  2894.            GLuint i;
  2895.            for (i=0;i<16;i++) {
  2896.           m[i] = n[1+i].f;
  2897.            }
  2898.            gl_MultMatrixf( ctx, m );
  2899.         }
  2900.         break;
  2901.          case OPCODE_MULTI_TEXCOORD4:
  2902.             (*ctx->Exec.MultiTexCoord4f)( ctx, n[1].e,
  2903.                                           n[2].f, n[3].f, n[4].f, n[5].f );
  2904.             break;
  2905.          case OPCODE_ORTHO:
  2906.             gl_Ortho( ctx, n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
  2907.             break;
  2908.      case OPCODE_PASSTHROUGH:
  2909.         gl_PassThrough( ctx, n[1].f );
  2910.         break;
  2911.      case OPCODE_PIXEL_MAP:
  2912.         gl_PixelMapfv( ctx, n[1].e, n[2].i, (GLfloat *) n[3].data );
  2913.         break;
  2914.      case OPCODE_PIXEL_TRANSFER:
  2915.         gl_PixelTransferf( ctx, n[1].e, n[2].f );
  2916.         break;
  2917.      case OPCODE_PIXEL_ZOOM:
  2918.         gl_PixelZoom( ctx, n[1].f, n[2].f );
  2919.         break;
  2920.      case OPCODE_POINT_SIZE:
  2921.         gl_PointSize( ctx, n[1].f );
  2922.         break;
  2923.      case OPCODE_POINT_PARAMETERS:
  2924.         {
  2925.         GLfloat params[3];
  2926.         params[0] = n[2].f;
  2927.         params[1] = n[3].f;
  2928.         params[2] = n[4].f;
  2929.         gl_PointParameterfvEXT( ctx, n[1].e, params ); 
  2930.         }
  2931.         break;
  2932.      case OPCODE_POLYGON_MODE:
  2933.         gl_PolygonMode( ctx, n[1].e, n[2].e );
  2934.         break;
  2935.      case OPCODE_POLYGON_STIPPLE:
  2936.         gl_PolygonStipple( ctx, (GLuint *) n[1].data );
  2937.         break;
  2938.      case OPCODE_POLYGON_OFFSET:
  2939.         gl_PolygonOffset( ctx, n[1].f, n[2].f );
  2940.         break;
  2941.      case OPCODE_POP_ATTRIB:
  2942.         gl_PopAttrib( ctx );
  2943.         break;
  2944.      case OPCODE_POP_MATRIX:
  2945.         gl_PopMatrix( ctx );
  2946.         break;
  2947.      case OPCODE_POP_NAME:
  2948.         gl_PopName( ctx );
  2949.         break;
  2950.      case OPCODE_PRIORITIZE_TEXTURE:
  2951.             gl_PrioritizeTextures( ctx, 1, &n[1].ui, &n[2].f );
  2952.         break;
  2953.      case OPCODE_PUSH_ATTRIB:
  2954.         gl_PushAttrib( ctx, n[1].bf );
  2955.         break;
  2956.      case OPCODE_PUSH_MATRIX:
  2957.         gl_PushMatrix( ctx );
  2958.         break;
  2959.      case OPCODE_PUSH_NAME:
  2960.         gl_PushName( ctx, n[1].ui );
  2961.         break;
  2962.      case OPCODE_RASTER_POS:
  2963.             gl_RasterPos4f( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
  2964.         break;
  2965.      case OPCODE_READ_BUFFER:
  2966.         gl_ReadBuffer( ctx, n[1].e );
  2967.         break;
  2968.          case OPCODE_RECTF:
  2969.             gl_Rectf( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
  2970.             break;
  2971.          case OPCODE_SELECT_TEXTURE:
  2972.             gl_SelectTexture( ctx, n[1].e );
  2973.             break;
  2974.          case OPCODE_SELECT_TEXTURE_SGIS:
  2975.             gl_SelectTextureSGIS( ctx, n[1].e );
  2976.             break;
  2977.          case OPCODE_SELECT_TEXTURE_COORD_SET:
  2978.             gl_SelectTextureCoordSet( ctx, n[1].e );
  2979.             break;
  2980.          case OPCODE_SELECT_TEXTURE_TRANSFORM:
  2981.             gl_SelectTextureTransform( ctx, n[1].e );
  2982.             break;
  2983.          case OPCODE_SCALE:
  2984.             gl_Scalef( ctx, n[1].f, n[2].f, n[3].f );
  2985.             break;
  2986.      case OPCODE_SCISSOR:
  2987.         gl_Scissor( ctx, n[1].i, n[2].i, n[3].i, n[4].i );
  2988.         break;
  2989.      case OPCODE_SHADE_MODEL:
  2990.         gl_ShadeModel( ctx, n[1].e );
  2991.         break;
  2992.      case OPCODE_STENCIL_FUNC:
  2993.         gl_StencilFunc( ctx, n[1].e, n[2].i, n[3].ui );
  2994.         break;
  2995.      case OPCODE_STENCIL_MASK:
  2996.         gl_StencilMask( ctx, n[1].ui );
  2997.         break;
  2998.      case OPCODE_STENCIL_OP:
  2999.         gl_StencilOp( ctx, n[1].e, n[2].e, n[3].e );
  3000.         break;
  3001.          case OPCODE_TEXENV:
  3002.             {
  3003.                GLfloat params[4];
  3004.                params[0] = n[3].f;
  3005.                params[1] = n[4].f;
  3006.                params[2] = n[5].f;
  3007.                params[3] = n[6].f;
  3008.                gl_TexEnvfv( ctx, n[1].e, n[2].e, params );
  3009.             }
  3010.             break;
  3011.          case OPCODE_TEXGEN:
  3012.             {
  3013.                GLfloat params[4];
  3014.                params[0] = n[3].f;
  3015.                params[1] = n[4].f;
  3016.                params[2] = n[5].f;
  3017.                params[3] = n[6].f;
  3018.                gl_TexGenfv( ctx, n[1].e, n[2].e, params );
  3019.             }
  3020.             break;
  3021.          case OPCODE_TEXPARAMETER:
  3022.             {
  3023.                GLfloat params[4];
  3024.                params[0] = n[3].f;
  3025.                params[1] = n[4].f;
  3026.                params[2] = n[5].f;
  3027.                params[3] = n[6].f;
  3028.                gl_TexParameterfv( ctx, n[1].e, n[2].e, params );
  3029.             }
  3030.             break;
  3031.      case OPCODE_TEX_IMAGE1D:
  3032.         gl_TexImage1D( ctx,
  3033.                            n[1].e, /* target */
  3034.                            n[2].i, /* level */
  3035.                            n[3].i, /* components */
  3036.                            n[4].i, /* width */
  3037.                            n[5].e, /* border */
  3038.                            n[6].e, /* format */
  3039.                            n[7].e, /* type */
  3040.                            (struct gl_image *) n[8].data );
  3041.         break;
  3042.      case OPCODE_TEX_IMAGE2D:
  3043.         gl_TexImage2D( ctx,
  3044.                            n[1].e, /* target */
  3045.                            n[2].i, /* level */
  3046.                            n[3].i, /* components */
  3047.                            n[4].i, /* width */
  3048.                            n[5].i, /* height */
  3049.                            n[6].e, /* border */
  3050.                            n[7].e, /* format */
  3051.                            n[8].e, /* type */
  3052.                            (struct gl_image *) n[9].data );
  3053.         break;
  3054.          case OPCODE_TEX_IMAGE3D:
  3055.             gl_TexImage3DEXT( ctx,
  3056.                               n[1].e, /* target */
  3057.                               n[2].i, /* level */
  3058.                               n[3].i, /* components */
  3059.                               n[4].i, /* width */
  3060.                               n[5].i, /* height */
  3061.                               n[6].i, /* depth  */
  3062.                               n[7].e, /* border */
  3063.                               n[8].e, /* format */
  3064.                               n[9].e, /* type */
  3065.                               (struct gl_image *) n[10].data );
  3066.             break;
  3067.          case OPCODE_TEX_SUB_IMAGE1D:
  3068.             gl_TexSubImage1D( ctx, n[1].e, n[2].i, n[3].i, n[4].i, n[5].e,
  3069.                               n[6].e, (struct gl_image *) n[7].data );
  3070.             break;
  3071.          case OPCODE_TEX_SUB_IMAGE2D:
  3072.             gl_TexSubImage2D( ctx, n[1].e, n[2].i, n[3].i, n[4].i, n[5].e,
  3073.                               n[6].i, n[7].e, n[8].e,
  3074.                               (struct gl_image *) n[9].data );
  3075.             break;
  3076.          case OPCODE_TEX_SUB_IMAGE3D:
  3077.             gl_TexSubImage3DEXT( ctx, n[1].e, n[2].i, n[3].i, n[4].i, n[5].i,
  3078.                                  n[6].i, n[7].i, n[8].i, n[9].e, n[10].e,
  3079.                                  (struct gl_image *) n[11].data );
  3080.             break;
  3081.          case OPCODE_TRANSLATE:
  3082.             gl_Translatef( ctx, n[1].f, n[2].f, n[3].f );
  3083.             break;
  3084.      case OPCODE_VIEWPORT:
  3085.         gl_Viewport( ctx,
  3086.                          n[1].i, n[2].i, (GLsizei) n[3].i, (GLsizei) n[4].i );
  3087.         break;
  3088.      case OPCODE_WINDOW_POS:
  3089.             gl_WindowPos4fMESA( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
  3090.         break;
  3091.      case OPCODE_CONTINUE:
  3092.         n = (Node *) n[1].next;
  3093.         break;
  3094.      case OPCODE_END_OF_LIST:
  3095.         done = GL_TRUE;
  3096.         break;
  3097.      default:
  3098.             {
  3099.                char msg[1000];
  3100.                sprintf(msg, "Error in execute_list: opcode=%d", (int) opcode);
  3101.                gl_problem( ctx, msg );
  3102.             }
  3103.             done = GL_TRUE;
  3104.       }
  3105.  
  3106.       /* increment n to point to next compiled command */
  3107.       if (opcode!=OPCODE_CONTINUE) {
  3108.      n += InstSize[opcode];
  3109.       }
  3110.  
  3111.    }
  3112.    ctx->CallDepth--;
  3113. }
  3114.  
  3115.  
  3116.  
  3117. /**********************************************************************/
  3118. /*                           GL functions                             */
  3119. /**********************************************************************/
  3120.  
  3121.  
  3122.  
  3123. /*
  3124.  * Test if a display list number is valid.
  3125.  */
  3126. GLboolean gl_IsList( GLcontext *ctx, GLuint list )
  3127. {
  3128.    if (list > 0 && HashLookup(ctx->Shared->DisplayList, list)) {
  3129.       return GL_TRUE;
  3130.    }
  3131.    else {
  3132.       return GL_FALSE;
  3133.    }
  3134. }
  3135.  
  3136.  
  3137.  
  3138. /*
  3139.  * Delete a sequence of consecutive display lists.
  3140.  */
  3141. void gl_DeleteLists( GLcontext *ctx, GLuint list, GLsizei range )
  3142. {
  3143.    GLuint i;
  3144.  
  3145.    if (INSIDE_BEGIN_END(ctx)) {
  3146.       gl_error( ctx, GL_INVALID_OPERATION, "glDeleteLists" );
  3147.       return;
  3148.    }
  3149.    if (range<0) {
  3150.       gl_error( ctx, GL_INVALID_VALUE, "glDeleteLists" );
  3151.       return;
  3152.    }
  3153.    for (i=list;i<list+range;i++) {
  3154.       gl_destroy_list( ctx, i );
  3155.    }
  3156. }
  3157.  
  3158.  
  3159.  
  3160. /*
  3161.  * Return a display list number, n, such that lists n through n+range-1
  3162.  * are free.
  3163.  */
  3164. GLuint gl_GenLists( GLcontext *ctx, GLsizei range )
  3165. {
  3166.    GLuint base;
  3167.  
  3168.    if (INSIDE_BEGIN_END(ctx)) {
  3169.       gl_error( ctx, GL_INVALID_OPERATION, "glGenLists" );
  3170.       return 0;
  3171.    }
  3172.    if (range<0) {
  3173.       gl_error( ctx, GL_INVALID_VALUE, "glGenLists" );
  3174.       return 0;
  3175.    }
  3176.    if (range==0) {
  3177.       return 0;
  3178.    }
  3179.  
  3180.    base = HashFindFreeKeyBlock(ctx->Shared->DisplayList, range);
  3181.    if (base) {
  3182.       /* reserve the list IDs by with empty/dummy lists */
  3183.       GLint i;
  3184.       for (i=0; i<range; i++) {
  3185.          HashInsert(ctx->Shared->DisplayList, base+i, make_empty_list());
  3186.       }
  3187.    }
  3188.    return base;
  3189. }
  3190.  
  3191.  
  3192.  
  3193. /*
  3194.  * Begin a new display list.
  3195.  */
  3196. void gl_NewList( GLcontext *ctx, GLuint list, GLenum mode )
  3197. {
  3198.    if (INSIDE_BEGIN_END(ctx)) {
  3199.       gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
  3200.       return;
  3201.    }
  3202.    if (list==0) {
  3203.       gl_error( ctx, GL_INVALID_VALUE, "glNewList" );
  3204.       return;
  3205.    }
  3206.    if (mode!=GL_COMPILE && mode!=GL_COMPILE_AND_EXECUTE) {
  3207.       gl_error( ctx, GL_INVALID_ENUM, "glNewList" );
  3208.       return;
  3209.    }
  3210.    if (ctx->CurrentListPtr) {
  3211.       /* already compiling a display list */
  3212.       gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
  3213.       return;
  3214.    }
  3215.  
  3216.    /* Allocate new display list */
  3217.    ctx->CurrentListNum = list;
  3218.    ctx->CurrentListPtr = ctx->CurrentBlock = (Node *) malloc( sizeof(Node) * BLOCK_SIZE );
  3219.    ctx->CurrentPos = 0;
  3220.  
  3221.    ctx->CompileFlag = GL_TRUE;
  3222.    if (mode==GL_COMPILE) {
  3223.       ctx->ExecuteFlag = GL_FALSE;
  3224.    }
  3225.    else {
  3226.       /* Compile and execute */
  3227.       ctx->ExecuteFlag = GL_TRUE;
  3228.    }
  3229.  
  3230.    ctx->API = ctx->Save;  /* Switch the API function pointers */
  3231. }
  3232.  
  3233.  
  3234.  
  3235. /*
  3236.  * End definition of current display list.
  3237.  */
  3238. void gl_EndList( GLcontext *ctx )
  3239. {
  3240.    /* Check that a list is under construction */
  3241.    if (!ctx->CurrentListPtr) {
  3242.       gl_error( ctx, GL_INVALID_OPERATION, "glEndList" );
  3243.       return;
  3244.    }
  3245.  
  3246.    (void) alloc_instruction( ctx, OPCODE_END_OF_LIST, 0 );
  3247.  
  3248.    /* Destroy old list, if any */
  3249.    gl_destroy_list(ctx, ctx->CurrentListNum);
  3250.    /* Install the list */
  3251.    HashInsert(ctx->Shared->DisplayList, ctx->CurrentListNum, ctx->CurrentListPtr);
  3252.  
  3253.    ctx->CurrentListNum = 0;
  3254.    ctx->CurrentListPtr = NULL;
  3255.    ctx->ExecuteFlag = GL_TRUE;
  3256.    ctx->CompileFlag = GL_FALSE;
  3257.  
  3258.    ctx->API = ctx->Exec;   /* Switch the API function pointers */
  3259. }
  3260.  
  3261.  
  3262.  
  3263. void gl_CallList( GLcontext *ctx, GLuint list )
  3264. {
  3265.    /* VERY IMPORTANT:  Save the CompileFlag status, turn it off, */
  3266.    /* execute the display list, and restore the CompileFlag. */
  3267.    GLboolean save_compile_flag;
  3268.    save_compile_flag = ctx->CompileFlag;
  3269.    ctx->CompileFlag = GL_FALSE;
  3270.    execute_list( ctx, list );
  3271.    ctx->CompileFlag = save_compile_flag;
  3272.  
  3273.    /* also restore API function pointers to point to "save" versions */
  3274.    if (save_compile_flag)
  3275.            ctx->API = ctx->Save;
  3276. }
  3277.  
  3278.  
  3279.  
  3280. /*
  3281.  * Execute glCallLists:  call multiple display lists.
  3282.  */
  3283. void gl_CallLists( GLcontext *ctx,
  3284.                    GLsizei n, GLenum type, const GLvoid *lists )
  3285. {
  3286.    GLuint list;
  3287.    GLint i;
  3288.    GLboolean save_compile_flag;
  3289.  
  3290.    /* Save the CompileFlag status, turn it off, execute display list,
  3291.     * and restore the CompileFlag.
  3292.     */
  3293.    save_compile_flag = ctx->CompileFlag;
  3294.    ctx->CompileFlag = GL_FALSE;
  3295.  
  3296.    for (i=0;i<n;i++) {
  3297.       list = translate_id( i, type, lists );
  3298.       execute_list( ctx, ctx->List.ListBase + list );
  3299.    }
  3300.  
  3301.    ctx->CompileFlag = save_compile_flag;
  3302.  
  3303.    /* also restore API function pointers to point to "save" versions */
  3304.    if (save_compile_flag)
  3305.            ctx->API = ctx->Save;
  3306. }
  3307.  
  3308.  
  3309.  
  3310. /*
  3311.  * Set the offset added to list numbers in glCallLists.
  3312.  */
  3313. void gl_ListBase( GLcontext *ctx, GLuint base )
  3314. {
  3315.    if (INSIDE_BEGIN_END(ctx)) {
  3316.       gl_error( ctx, GL_INVALID_OPERATION, "glListBase" );
  3317.       return;
  3318.    }
  3319.    ctx->List.ListBase = base;
  3320. }
  3321.  
  3322.  
  3323.  
  3324.  
  3325. /***
  3326.  *** Debugging code
  3327.  ***/
  3328.  
  3329. static char tmp[1000];
  3330.  
  3331. static char *enum_string( GLenum k )
  3332. {
  3333.    /* TODO: Add many more constant/string entries */
  3334.    switch (k) {
  3335.       case GL_POINTS:        return "GL_POINTS";
  3336.       case GL_LINES:        return "GL_LINES";
  3337.       case GL_LINE_STRIP:    return "GL_LINE_STRIP";
  3338.       case GL_LINE_LOOP:    return "GL_LINE_LOOP";
  3339.       case GL_TRIANGLES:    return "GL_TRIANGLES";
  3340.       case GL_TRIANGLE_STRIP:    return "GL_TRIANGLE_STRIP";
  3341.       case GL_TRIANGLE_FAN:    return "GL_TRIANGLE_FAN";
  3342.       case GL_QUADS:        return "GL_QUADS";
  3343.       case GL_QUAD_STRIP:    return "GL_QUAD_STRIP";
  3344.       case GL_POLYGON:        return "GL_POLYGON";
  3345.       case GL_FRONT:        return "GL_FRONT";
  3346.       case GL_BACK:        return "GL_BACK";
  3347.       case GL_FRONT_AND_BACK:    return "GL_FRONT_AND_BACK";
  3348.       case GL_AMBIENT:        return "GL_AMBIENT";
  3349.       case GL_DIFFUSE:        return "GL_DIFFUSE";
  3350.       case GL_SPECULAR:        return "GL_SPECULAR";
  3351.       case GL_SHININESS:    return "GL_SHININESS";
  3352.       default:
  3353.          sprintf(tmp,"0x%X", k);
  3354.          return tmp;
  3355.    }
  3356. }
  3357.  
  3358.  
  3359. /*
  3360.  * Print the commands in a display list.  For debugging only.
  3361.  * TODO: many commands aren't handled yet.
  3362.  */
  3363. static void print_list( GLcontext *ctx, FILE *f, GLuint list )
  3364. {
  3365.    Node *n;
  3366.    GLboolean done;
  3367.    OpCode opcode;
  3368.  
  3369.    if (!glIsList(list)) {
  3370.       fprintf(f,"%d is not a display list ID\n",list);
  3371.       return;
  3372.    }
  3373.  
  3374.    n = (Node *) HashLookup(ctx->Shared->DisplayList, list);
  3375.  
  3376.    fprintf( f, "START-LIST %d, address %p\n", list, (void*)n );
  3377.  
  3378.    done = n ? GL_FALSE : GL_TRUE;
  3379.    while (!done) {
  3380.       opcode = n[0].opcode;
  3381.  
  3382.       switch (opcode) {
  3383.          case OPCODE_ACCUM:
  3384.             fprintf(f,"accum %d %g\n", n[1].e, n[2].f );
  3385.         break;
  3386.          case OPCODE_BEGIN:
  3387.             fprintf(f,"Begin %s\n", enum_string(n[1].e) );
  3388.             break;
  3389.      case OPCODE_BITMAP:
  3390.             fprintf(f,"Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
  3391.                n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data );
  3392.         break;
  3393.          case OPCODE_CALL_LIST:
  3394.             fprintf(f,"CallList %d\n", (int) n[1].ui );
  3395.             break;
  3396.          case OPCODE_CALL_LIST_OFFSET:
  3397.             fprintf(f,"CallList %d + offset %d = %d\n", (int) n[1].ui,
  3398.                     ctx->List.ListBase, ctx->List.ListBase + n[1].ui );
  3399.             break;
  3400.      case OPCODE_COLOR_3F:
  3401.             fprintf(f,"Color3f %g %g %gn", n[1].f, n[2].f, n[3].f );
  3402.         break;
  3403.      case OPCODE_COLOR_4F:
  3404.             fprintf(f,"Color4f %g %g %g %g\n", n[1].f, n[2].f, n[3].f, n[4].f);
  3405.         break;
  3406.      case OPCODE_COLOR_4UB:
  3407.             fprintf(f,"Color4ub %d %d %d %d\n", n[1].ub, n[2].ub,
  3408.                                                 n[3].ub, n[4].ub );
  3409.         break;
  3410.      case OPCODE_DISABLE:
  3411.             fprintf(f,"Disable %s\n", enum_string(n[1].e));
  3412.         break;
  3413.      case OPCODE_ENABLE:
  3414.             fprintf(f,"Enable %s\n", enum_string(n[1].e));
  3415.         break;
  3416.          case OPCODE_END:
  3417.             fprintf(f,"End\n");
  3418.             break;
  3419.          case OPCODE_FRUSTUM:
  3420.             fprintf(f,"Frustum %g %g %g %g %g %g\n",
  3421.                     n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
  3422.             break;
  3423.          case OPCODE_INDEX:
  3424.             fprintf(f,"Index %d\n", (int) n[1].ui );
  3425.             break;
  3426.      case OPCODE_LINE_STIPPLE:
  3427.         fprintf(f,"LineStipple %d %x\n", n[1].i, (int) n[2].us );
  3428.         break;
  3429.      case OPCODE_LOAD_IDENTITY:
  3430.             fprintf(f,"LoadIdentity\n");
  3431.         break;
  3432.      case OPCODE_LOAD_MATRIX:
  3433.             fprintf(f,"LoadMatrix\n");
  3434.             fprintf(f,"  %8f %8f %8f %8f\n", n[1].f, n[5].f,  n[9].f, n[13].f);
  3435.             fprintf(f,"  %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f);
  3436.             fprintf(f,"  %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f);
  3437.             fprintf(f,"  %8f %8f %8f %8f\n", n[4].f, n[8].f, n[12].f, n[16].f);
  3438.         break;
  3439.      case OPCODE_MATERIAL:
  3440.             fprintf(f,"Material %s %s %g %g %g %g\n", enum_string(n[1].e),
  3441.                     enum_string(n[2].e), n[3].f, n[4].f, n[5].f, n[6].f );
  3442.             break;
  3443.      case OPCODE_MULT_MATRIX:
  3444.             fprintf(f,"MultMatrix (or Rotate)\n");
  3445.             fprintf(f,"  %8f %8f %8f %8f\n", n[1].f, n[5].f,  n[9].f, n[13].f);
  3446.             fprintf(f,"  %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f);
  3447.             fprintf(f,"  %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f);
  3448.             fprintf(f,"  %8f %8f %8f %8f\n", n[4].f, n[8].f, n[12].f, n[16].f);
  3449.         break;
  3450.          case OPCODE_NORMAL:
  3451.             fprintf(f,"Normal %g %g %g\n", n[1].f, n[2].f, n[3].f );
  3452.             break;
  3453.          case OPCODE_ORTHO:
  3454.             fprintf(f,"Ortho %g %g %g %g %g %g\n",
  3455.                     n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
  3456.             break;
  3457.      case OPCODE_POP_ATTRIB:
  3458.             fprintf(f,"PopAttrib\n");
  3459.         break;
  3460.      case OPCODE_POP_MATRIX:
  3461.             fprintf(f,"PopMatrix\n");
  3462.         break;
  3463.      case OPCODE_POP_NAME:
  3464.             fprintf(f,"PopName\n");
  3465.         break;
  3466.      case OPCODE_PUSH_ATTRIB:
  3467.             fprintf(f,"PushAttrib %x\n", n[1].bf );
  3468.         break;
  3469.      case OPCODE_PUSH_MATRIX:
  3470.             fprintf(f,"PushMatrix\n");
  3471.         break;
  3472.      case OPCODE_PUSH_NAME:
  3473.             fprintf(f,"PushName %d\n", (int) n[1].ui );
  3474.         break;
  3475.      case OPCODE_RASTER_POS:
  3476.             fprintf(f,"RasterPos %g %g %g %g\n", n[1].f, n[2].f,n[3].f,n[4].f);
  3477.         break;
  3478.          case OPCODE_RECTF:
  3479.             fprintf( f, "Rectf %g %g %g %g\n", n[1].f, n[2].f, n[3].f, n[4].f);
  3480.             break;
  3481.          case OPCODE_SCALE:
  3482.             fprintf(f,"Scale %g %g %g\n", n[1].f, n[2].f, n[3].f );
  3483.             break;
  3484.      case OPCODE_TEXCOORD2:
  3485.             fprintf(f,"TexCoord %g %g\n", n[1].f, n[2].f);
  3486.         break;
  3487.      case OPCODE_TEXCOORD4:
  3488.             fprintf(f,"TexCoord %g %g %g %g\n", n[1].f, n[2].f, n[3].f,n[4].f);
  3489.         break;
  3490.          case OPCODE_TRANSLATE:
  3491.             fprintf(f,"Translate %g %g %g\n", n[1].f, n[2].f, n[3].f );
  3492.             break;
  3493.          case OPCODE_VERTEX2:
  3494.             fprintf(f,"Vertex %g %g\n", n[1].f, n[2].f );
  3495.             break;
  3496.          case OPCODE_VERTEX3:
  3497.             fprintf(f,"Vertex %g %g %g\n", n[1].f, n[2].f, n[3].f );
  3498.             break;
  3499.          case OPCODE_VERTEX4:
  3500.             fprintf(f,"Vertex %g %g %g %g\n", n[1].f, n[2].f, n[3].f, n[4].f );
  3501.             break;
  3502.  
  3503.      /*
  3504.       * meta opcodes/commands
  3505.       */
  3506.      case OPCODE_CONTINUE:
  3507.             fprintf(f,"DISPLAY-LIST-CONTINUE\n");
  3508.         n = (Node *) n[1].next;
  3509.         break;
  3510.      case OPCODE_END_OF_LIST:
  3511.             fprintf(f,"END-LIST %d\n", list);
  3512.         done = GL_TRUE;
  3513.         break;
  3514.          default:
  3515.             if (opcode < 0 || opcode > OPCODE_END_OF_LIST) {
  3516.                fprintf(f,"ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
  3517.                        opcode, (void*) n);
  3518.                return;
  3519.             }
  3520.             else {
  3521.                fprintf(f,"command %d, %d operands\n",opcode,InstSize[opcode]);
  3522.             }
  3523.       }
  3524.  
  3525.       /* increment n to point to next compiled command */
  3526.       if (opcode!=OPCODE_CONTINUE) {
  3527.      n += InstSize[opcode];
  3528.       }
  3529.  
  3530.    }
  3531. }
  3532.  
  3533.  
  3534.  
  3535. /*
  3536.  * Clients may call this function to help debug display list problems.
  3537.  * This function is _ONLY_FOR_DEBUGGING_PURPOSES_.  It may be removed,
  3538.  * changed, or break in the future without notice.
  3539.  */
  3540. void mesa_print_display_list( GLuint list )
  3541. {
  3542.    GLcontext *ctx;
  3543. #ifdef THREADS
  3544.    ctx = gl_get_thread_context();
  3545. #else
  3546.    ctx = CC;
  3547. #endif
  3548.    print_list( ctx, stdout, list );
  3549. }
  3550.